[英]Python 2.7.3 - Function not returning the right values in a string formatted table
[英]function not returning string values
我想从我的消息函数返回m&t的字符串值,以在密码函数中使用它来执行while循环,并且一旦错误打印消息就会反转。 我收到的错误消息是“ NameError:未定义名称'm'”,但是在消息中定义了“ m”,我试图将其与“ t”一起返回用于密码。
def main():
message()
cipher(m, t)
def message():
m = input("Enter your message: ")
t = ''
return m, t
def cipher(m, t):
i = len(m) - 1
while i >= 0:
t = t + m[i]
i -= 1
print(t)
if __name__ == '__main__': main()
调用message()
函数时,需要存储返回值。
def main():
m, t = message()
cipher(m, t)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.