【发布时间】:2019-09-20 21:25:22
【问题描述】:
我希望当玩家拒绝时说再见然后结束,而是转到选择一个类别。有什么建议吗?
while True:
choice = input ("Do you want to play?")
if choice == "yes":
print("Great!")
break # Go to the game
elif choice == "no":
print("Goodbye.")
break # nothing
else:
print("Please answer yes or no.")
continent = input("Choose a category: \n"
"Africa \n"
"Asia \n"
"Antarctica \n"
"Australia \n"
"Europe \n"
"North America \n"
"South America \n")
这个问题不同,因为它不是询问循环,而是询问如何正确结束程序。
【问题讨论】:
-
你提到的循环在哪里?
标签: python python-3.x if-statement while-loop