函数不返回字符串值

use*_*939 0 python function return-value

我想从我的消息函数返回m&t的字符串值,以在密码函数中使用以执行while循环,并且一旦错误打印消息反向.我收到的错误消息是"NameError:name'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()
Run Code Online (Sandbox Code Playgroud)

kin*_*pps 5

调用message()函数时,需要存储返回值.

def main():
    m, t = message()
    cipher(m, t)
Run Code Online (Sandbox Code Playgroud)