我正在製作一個文本冒險遊戲,我試圖讓用戶使用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