为什么这会给我错误'return' outside function
?在
Result = ""
char = ""
# Let char loop over each character in the input string
a = list(s)
for i in range (0, len(s)):
# If this char is a letter:
if (type(a[i])=='str'):
# Set char_low to be char converted to lower case
char_low = a.lower()
print a
# Note: the next 5 lines do not need to be changed -
# they will modify the character as necessary
if char_low <= 'm':
dist = 13
else:
dist = -13
char = chr(ord(char) + dist)
# Push char onto the end of the result
result = result + char
# Return the encrypted text
return result
return
语句只能在函数定义中使用,例如:如果结果是一个退出代码,您可能希望使用
sys.exit(result)
,或者更可能的是,将结果打印到控制台,在这种情况下,只需使用print(result)
。在好吧,因为回报是函数之外的。在
相关问题 更多 >
编程相关推荐