用户提示选择自己的冒险游戏

时间:2017-02-20 11:22:00

标签: python conditional user-input

已经搜索了一个python选择你自己的冒险游戏,但我发现的最接近的是基于文本的游戏'Droids',我使用了一些代码来创建下面的条件,根据用户输入打印一本书的页面。我的问题是如何创建一个条件,在每个页面显示给用户并返回正确的页面后会提示,然后显示一个新提示以继续故事。

#Defines the first page that is displayed
def page0():
    print "\n %s" % firstpage

def page3():
    print "\n %s" % thirdpage

def page10():
    print "\n %s" % tenthpage

#prints page 0
print page0()

#Choice 1 returns page 3 or 10 
ch1 = str(input("Type 3 or 10: "))


if ch1 in ['3']:
   print (thirdpage)

elif ch1 in ['10']:
    print (tenthpage)

1 个答案:

答案 0 :(得分:0)

循环while功能帮助我摆脱了'roganjosh,WhatsThePoint'的礼貌

while True:
    inp = raw_input(">>> ").lower()
相关问题