重启python程序

时间:2014-10-06 02:52:26

标签: python

我正在尝试在python中重新启动我的程序,但是,由于某种原因,代码在while playagain循环中被捕获。它说"这不是一个有效的答案。请输入“是”'或者' no'。"当我输入yes,no或任何其他可接受的输入时。为什么要赢得这项工作呢?

while True:
    playagain = input("Would you like to play again?")
    while playagain != "y" or playagain != "Y" or playagain != "Yes" or playagain != "yes" or playagain != "YES" or playagain != "n" or playagain != "N" or playagain != "No" or playagain != "no" or playagain != "NO":
         print("That was not a valid answer. Please enter 'yes' or 'no'.")
         playagain = input("Would you like to play again?")
    if playagain == "y" or playagain == "Y" or playagain == "Yes" or playagain == "yes" or playagain == "YES":
         break
    else:
         print("Thank you for playing MadLibs!")

0 个答案:

没有答案