PYTHON - 关键词输入列表

时间:2014-06-10 22:51:20

标签: python python-2.7 python-idle

我已经设定了如果'是啊'在输入它输出一定的责任,但我希望它理解是,是的,是的。这是代码!

name = raw_input ("What's your name?")

if 'Sean' in name:    
name1 = raw_input("Downey or Paul?")        
if 'Downey' in name1:    
    print ("Hi Sean Downey")
    x = raw_input("Did you know that the name is irish?")
    if x == 'yea':
        print ('oh cool')
elif 'Paul' in name1:    
    print ("Hi Sean Paul")    
else:    
    print ("I don't know that Sean")
else:    
print ('Hi %s') % (name)

1 个答案:

答案 0 :(得分:1)

您可以将确认放在元组中,并检查元组中是否有x

confirmations = ('yeah', 'yes', 'yea')
if x in confirmations:
    ...