While循环基于if语句循环但不检查

2024-04-18 11:26:10 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图让用户检查他们的个人资料时,要求他们所有的方式,这就是我正在做的。问题是,当我运行它时,我可以使用if函数的一个while条件(使程序结束),但之后我就不知道发生了什么。它显然一直在循环,但程序没有结束,我不能使用其他if函数,有什么想法吗?你知道吗

print("ask about your stats")
userInput = input()
while userInput != "Pass":
    if userInput == "Stats":
        print(billyMays)
    elif userInput == "Health":
        print(health)
    elif userInput == "Hunger":
        print(hunger)
    elif userInput == "Voice":
        print(voice)
    else:
        pass
    userInput = None
print("goodbye")

Tags: 函数用户程序yourifstats方式条件