而循环python故障

Mat*_*y G 1 python terminal python-2.7

我最近在高中做了一个gamedev课程,我们一直在使用Mac的终端运行python编码来制作基于文本的游戏.我认为这是python 2.7的一个版本,我遇到了一个错误

while Menuselect != "play":
    MenuSelect = raw_input("Type 'quit' to exit - 'credits' for credits - Type 'play' to start\n")
    MenuSelect = MenuSelect.lower()
    if MenuSelect == "quit":
        SystemExit(0)
    elif MenuSelect == "credits":
        print("Lmao, only Matt made this")
    else:
        print("You mistyped. 10/10")

print(": You wake up in a dark room, you don't know where you are or how you got here :")
Run Code Online (Sandbox Code Playgroud)

当我尝试运行它并输入'play'来停止循环时,它会再次继续循环.有什么问题吗?

Lgi*_*iro 6

您正在使用小写"s"检查变量名称"Menuselect",但将raw_input分配给名为"MenuSelect"的变量,其大写为"S".将'while'语句更改为

while MenuSelect != "play":
Run Code Online (Sandbox Code Playgroud)

它应该工作.