我正在学习 Python,但遇到了一些问题。在我正在学习的课程中看到类似的东西后想出了这个简短的脚本。我之前成功地使用了“或”和“如果”(这里没有显示太多)。出于某种原因,我似乎无法使其正常工作:
test = raw_input("It's the flying circus! Cool animals but which is the best?")
x = test.lower()
if x == "monkey" or "monkeys":
print "You're right, they are awesome!!"
elif x != "monkey" or "monkeys":
print "I'm sorry, you're incorrect.", x[0].upper() + x[1:], "is not the right animal."
但这很好用:
test = raw_input("It's the flying circus! Cool animals but which is the best?")
x = test.lower()
if x == "monkey":
print "You're right, they are awesome!!"
elif x != "monkey":
print "I'm sorry, you're incorrect.", x[0].upper() + x[1:], "is not the right animal."
可能 or 条件不适合这里。但是我已经尝试过,等等。我希望有一种方法可以让这个接受猴子或猴子,其他一切都会触发 elif。