首页 > 解决方案 > 其他声明表现得好像它不存在

问题描述

嗨,我是 python 新手,我正在编写这个快速项目,但是每当我在代码中添加一个 elif 语句时,它会完全忽略 else 语句并打印打破循环的 elif 语句有人知道为什么吗?

user_input7 = input("What is my favorite game?")
while True:
    if user_input7 =="Hint" or user_input7 == "hint":
        print("The first two letters of the first word start with ho.")
        user_input7 = input("What's my favorite game?")
        continue
    elif user_input7 == "idk" or user_input7 == "i dont know":
        print("uh if you don't know it type hint")
        user_input7 = input("What's my favorite game?")
        continue
    elif user_input7 == "Hollow Knight" or "hollow knight" or "Hollow knight":
        print("About time you got that one")
        break
    else:
        print("Why isn't this working")

标签: pythonpython-3.x

解决方案


推荐阅读