I would like to return the string values of m & t from my message function to use in cipher function to perform a while loop and once false print the message reverse. The error message I am receiving is "NameError: name 'm' is not defined", but 'm' has been defined in message which i am attempting to return for use in cipher along with '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()
When you call your message()
function, you need to store the return values.
def main():
m, t = message()
cipher(m, t)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.