好吧基本上我正在选择你自己的冒险故事,每次我运行代码无论你选择哪个选择,程序都会自动拉出故事的下一部分,我怎样才能让它在你之后结束死在故事中。
story = print(“这是夏季。你去了阿姨家,他带你去城里游览。 他带你到这座城市最着名的建筑。他告诉你,这座建筑物闹鬼但是 你不相信他。“)
choice_1 =输入(“你去里面还是留下来?”) 如果choice_1 ==“进去”: 打印(“你决定进去,你的阿姨说:”小心“你开始走上老鬼屋的石阶。” 你打开门走进去,突然一条锋利的箭头划过你的脸!但它错过了你。“)
choice_2 = input("Do you go up the staircase, into the kitchen, or do you run away?")
if choice_2 == "up the staircase":
print (" You compose yourself, and go up the staircase. as you begin to reach the top, the floor beneath you breaks open\
你死了“) elif choice_2 ==“进入厨房”: 打印(“你自己做,并决定通过厨房。它充满了cobb网络,没有其他有趣的东西。”) elif choice_2 ==“逃跑”: 打印(“你决定不进入鬼屋,和你的阿姨一起吃冰淇淋。”) 其他: 打印(“输入无效”)
choice_3 = input("you see two doors in front of you one is labeled \"1\" the other is labeled \"2\",\
你选择哪个门?输入1或2“)
如果choice_3 ==“1”:
打印(“你打开左边的门,然后走进去。一阵强风将你推开窗外,\
你掉进了灌木丛里。心不在焉,你遇到了姨妈然后开车去买冰淇淋“
elif choice_3 ==“2”:
打印(“你继续进入右边的门,房间后面有一个奇怪的棺材。”
棺材打开了,一个吸血鬼弹出来了。你的思绪一片空白,你在家里安全地在床上醒来。
你是阿姨带你去冰淇淋店,说你可以拥有尽可能多的勺子。“
choice_4 = int(input("How many scoops do you get?"))
if choice_4 < 4 and choice_4 > 0:
print ("you enjoy your ice cream, forget about what happened, and never go into another abandoned house again")
elif choice_4 == 0:
print ("you decide that you do not like ice cream anymore, and you try to forget about what happened,\
但你从经历的事件中慢慢变得疯狂“) 其他: 打印(“你吃了太多的冰淇淋然后呕吐”)
elif choice_1 ==(“逗留”): 打印(“你决定不进入鬼屋,和你的阿姨一起吃冰淇淋。”) 其他: 打印(“输入无效”)
答案 0 :(得分:0)
有几种方法可以创建该行为。一种方法是在选择导致&#34; death&#34;之后添加return
语句。退出函数:
def story():
choice_1 = input("choice")
if choice_1 in ["choices","that","don't","end","in","death"]:
print "you live and keep playing"
else:
return 0
choice_2 = input("choose again")
if choice_2 in ["choices","that","don't","end","in","death"]:
print "you live and keep playing"
else:
return 0
def the_end():
print "you're dead"
story()
the_end()