我已经搜索了一个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)
一个循环
while
函数帮助我解决了这个问题,这是由“roganjosh,whatthepoint”提供的相关问题 更多 >
编程相关推荐