我正在制作一个文本冒险游戏,我试图让用户使用q退出游戏。我不知道该输入什么,这是我的代码。如何让用户退出程序
print ("Welcome to Camel!")
print ("You have stolen a camel to make your way across the great Mobi deset.")
print ("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.")
print ("Welcome to Camel!")
print ("You have stolen a camel to make your way across the great Mobi deset.")
print ("The natives want their camel back and are chasing you down! Survive your desert trek and out run the natives.")
done = False
while done == False:
print("Print the letter only.")
print("A. Drink from your canteen.")
print("B. Ahead moderate speed.")
print("C. Ahead full speed.")
print("D. Stop for the night.")
print("E. Status check.")
print("Q. Quit.")
first_question = input("What do you want to do? ")
if first_question.lower() == "q":
done = True
if done == True:
quit
所有的行都在代码中正确缩进(当复制粘贴时,网站变得很奇怪)。任何帮助表示赞赏。
我把你的代码编辑成一个代码块。将来,您可以突出显示代码部分,然后单击带花括号的按钮{}'以缩进代码 – James
请参阅https://stackoverflow.com/questions/543309/programatically-stop-execution-of- python-script – AnilRedshift
什么是'退出'?也许你是用'()'来表示'break'或'quit()'。但删除'如果完成== True:退出',它应该按照您的预期工作。 – furas