2015-02-05 46 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某處: