Reputation: 829
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()
Upvotes: 0
Views: 228
Reputation: 3504
When you call your message()
function, you need to store the return values.
def main():
m, t = message()
cipher(m, t)
Upvotes: 5