基本的If语句不能正常工作 - Python

时间:2015-02-05 15:27:54

标签: python if-statement

此代码适用于我正在编写的基本冒险游戏。即使我在Python中输入'refuse'或'sdef',我也会一直死('你变成了工作狂......')。

帮助!!

from sys import exit

def dead(why):
   print why
   exit(0)

def nyc():
   print '''You arrive in NYC and have a bank job lined up. will you take it or leave it?'''

   choice = raw_input('> ')

   if 'take' or 'accept' in choice:
       dead('You become a workaholic and die of heart failure.')

   elif 'refuse' or 'decline' or 'leave' or 'not' in choice:
       bum()

   else:
       dead('Its banking or no deal buddy...you dead')

1 个答案:

答案 0 :(得分:1)

if 'take' in choice or 'accept' in choice:

正确就是这个。否则,if语句将始终排除True。你必须在那里写下每一个条件。

  • 错误

    如果在某处某事或某事1和某事2:

  • 正确

    如果在某处某事或在某处某事某事在某处某事某事: