我目前是一名新學生學習python。這是我第一次做大量計算機編碼的真實經歷。對於我的項目,我必須在三個不同難度級別的空白測驗中填寫。一旦用戶選擇了困難,遊戲應該根據難度打印不同的段落。遊戲的每個部分都能正常工作,但我在創建「難度選擇器」時遇到了麻煩。無論我選擇何種困難,遊戲都會依次輕鬆,中等和難度,然後崩潰。爲簡單遊戲創建決策樹
下面我已經加入了介紹性文字和難度選擇器。我會喜歡一些幫助。我確信有一些我看不到的明顯的東西。謝謝!
def introduction():
print '''Welcome to Kevin's European Geography Quizzes.
Test your knowledge of European geography. \n'''
difficulty = raw_input('''Do you want to play an easy, medium, or hard game?
Please type the number 1 for easy, 2 for medium, or 3 for hard.\n''')
game_chooser(difficulty)
def game_chooser(difficulty):
cursor = 0
difficulty_choice = [easy_game(), medium_game(), hard_game()]
#each element of the above list links to a procedure and starts one of the
#mini-games.
while cursor < len(difficulty_choice):
if difficulty != cursor:
cursor += 1
else:
difficulty_choice[cursor]
break
你需要一個條件來檢查輸入。它很難給你一個很好的答案與你分享。 – Joe