If statement 如何在特定输入后结束if-else语句
好的,基本上我是在做一个选择你自己的冒险故事,每次我运行代码,不管你选择哪一个选择,程序都会自动调出故事的下一部分,我如何使它在你死后或故事中的某个部分结束 又是夏天了。你去你姑妈家,他会带你环城游览\ 他带你去城里最有名的建筑。他告诉你那栋楼闹鬼,但是\ 你不相信他 选择_1=输入你是进去还是留下? 如果选项_1==进入: 如果你决定进去,你姑妈说\小心\你开始走上鬼屋的石阶\ 你打开门走了进去,突然一支利箭划过你的脸!但它想念你If statement 如何在特定输入后结束if-else语句,if-statement,input,If Statement,Input,好的,基本上我是在做一个选择你自己的冒险故事,每次我运行代码,不管你选择哪一个选择,程序都会自动调出故事的下一部分,我如何使它在你死后或故事中的某个部分结束 又是夏天了。你去你姑妈家,他会带你环城游览\ 他带你去城里最有名的建筑。他告诉你那栋楼闹鬼,但是\ 你不相信他 选择_1=输入你是进去还是留下? 如果选项_1==进入: 如果你决定进去,你姑妈说\小心\你开始走上鬼屋的石阶\ 你打开门走了进去,突然一支利箭划过你的脸!但它想念你 choice_2 = input("Do you go up
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==进入厨房:
打印你自己,并决定通过厨房。它满是鹅卵石网,没有其他有趣的东西。
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
如果选项_3==1:
你打开左边的门走进去。一阵风把你吹出窗外\
然后你掉进了灌木丛,吓得魂不附体,你遇到了你的姑妈,开车离开,去买冰淇淋
elif选项_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==停留:
如果你决定不去鬼屋和你姑妈一起吃冰淇淋。
其他:
打印无效输入有几种方法可以创建该行为。一种方法是在导致退出函数死亡的选择之后添加return语句:
choice_3 = input("you see two doors in front of you one is labeled \"1\" the other is labeled \"2\",\
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()
这似乎是一篇文章:P