python怎么返回布尔值_尝试从函数返回布尔值

您需要将“return incomp1==True”替换为“return True”。然后像这样调用door1函数“incomp1=door1(incomp1)”。

这将把incomp1的值更改为函数“True”返回的值。在

也可以用简单的“else”替换“elif incomp1==True:”。在

您还可以考虑将.lower()添加到choice1=raw_input(“您的响应是什么?:>“)。这样一来,如果玩家在输入中使用一个大写字母,它仍然可以按需要工作。在def door1(incomp1):

if incomp1 == False:

print 'You enter door 1 and find a hideous internet troll.'

print "The troll says, 'LOOK AT THIS LOSER'"

options = ["YOU'RE THE LOSER", "I don't care." , "YOUR MOM IS FAT"]

options2 = [1,2,3]

for x in options:

print "\t :> %s" % x

#choice1 = raw_input("What is your response? :>")

choice1 = raw_input("What is your response? :>").lower()

if ('loser' in choice1) or ('fat' in choice1):

print "You are sucked into the troll's behaviour and are driven insane"

print "After three days of insanity, you starve to death"

dead()

elif 'care' in choice1:

print 'The troll cannot feed off of your anger.'

print 'The troll starves and you recover one piece of the lever from his stomach.'

change()

entrywayopen()

return True

else:

unknown()

change()

door1(incomp1)

#elif incomp1 == True:

else:

print 'You already recovered the piece from room 1.'

entrywayopen()

incomp1 = door1(incomp1)

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值