2015-02-05 93 views
0

此代码适用于我正在编写的基本冒险游戏。即使我在Python中输入'拒绝'或'sdef',我也会死去('你变成了工作狂等等')。基本If语句无法正常工作 - Python

帮助!!

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
if 'take' in choice or 'accept' in choice: 

正确的是这样的。否则您的if声明始终表明True。你必须写下所有的条件。

  • 错误

    如果事情或something1和something2在某处:

  • 正确

    如果事情在什么地方,或者something1在的地方,并在something2某处: