这是我的代码,我正在为游戏测试此代码,但至少需要降低基本技巧-
name = input("What is your name? ")
age = input("Welcome! How old are you? ")
print ("Hello, ", name, ", you are ", age, " years old, correct?")
print ("If so, type YES. If not, type NO.")
verifyNameAge = input("Input here: ")
if verifyNameAge == "yes" or "Yes" or "YES":
print ("Thank you for verifying.")
else:
print ("Restarting program.")
我希望当我在输入中输入“ no”时,它会打印“ closes program”,但会打印if结果(谢谢您的验证)
答案 0 :(得分:0)
问题出在您的最后一个if条件上,OR运算符中的第二和第三字符串将始终为True。
if条件应如下:
if verify_name_age in ( "yes", "Yes", "YES"):
print ("Thank you for verifying.")
else:
print ("Restarting program.")