python if 语句结束_让python以if语句结束程序

我正在创建一个游戏风格的程序,并正在寻找一个命令,将结束程序在某一点。没有语法错误,并且都在空闲中正确缩进。在

我希望这个命令在if语句的“YOU DIED GAME OVER”后执行。

我试着在网上找任何东西,但找不到任何提示。

以下代码buy2a = input ('Type Y to drink the strange liquid and type N not to')

if buy2a == 'Y' or buy2a == 'y':

chance2a = 2 #random.randint(1,4)

if chance2a == '2' or chance2a == '4' :

print ('You start to choke and you black out')

print ('YOU DIED')

print ('GAME OVER')

# >Thing im looking for goes here!

else :

print ('You feel strange')

time.sleep(1)

print ('You blackout but wake up several hours later')

time.sleep(1)

health = 20

print ('You feel a lot better and now have ' + str(health) + ' health')

else :

print ('You pass on the offer with a weak reason and head off in a hurry')

print ('You enter the next town on weiry feet')

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值