Python字符串比较无法按预期工作

时间:2015-05-25 13:01:05

标签: python string comparison

我使用python 2.7并尝试简单地从一个人那里获取一个输入(通过raw_input)然后根据输入的内容输出一个字符串,但我得到的行为是第一个逻辑在我的"如果"无论我输入什么,语句总是会执行。

为什么这不起作用?

another_card = raw_input("Another card: (Y or N) ")

print "The value of another_card is: " + another_card 

if another_card == "Y" or "y":
    print "Good on you"
elif another_card == "N" or "n":
    print "Wimp. Game over."
else:
    print "What the hell did you type?"

任何帮助将不胜感激。感谢。

0 个答案:

没有答案
相关问题