【发布时间】:2017-10-15 00:49:32
【问题描述】:
我目前是一名学习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
【问题讨论】:
-
您需要一个条件来检查输入。您分享的内容很难给您一个好的答案。
标签: python