【发布时间】:2023-03-09 18:25:01
【问题描述】:
好像你们编译代码一样,即使我的 if 语句和我的 while 循环是正确的,它们也不能一起工作,请帮助我
question_1_prologue = input("Are you ready to help me save the world?\na) Of course\nb) No\n")
print()
while question_1_prologue != "a" or "A" or "a)" or "A)":
print ("This game was not made for you")
break
if question_1_prologue == "a" or "A" or "a)" or "A)":
print ('Good choice, heroes never die')
当我们输入 a 时,“好选择,英雄永不死”会起作用,但如果您输入任何不同的内容,您将同时收到消息“英雄永不死”和“这个游戏不是为你而制作的”
【问题讨论】:
-
你能补充一下你得到的错误是什么吗?
-
用户输入后的
print()是不必要的,可以去掉。并且菜单选项似乎相同,因此无论哪种方式,它都将始终在该 while 循环中break并且永远不会到达if语句。
标签: python python-3.x pygame