samedi 27 décembre 2014

Python - 'in' keyword and if-statements not working as expected [duplicate]


This question already has an answer here:




I have looked for an answer to my question, but it seems there are none for my problem specifically. Which has lead me to believe this is a simple error.



def intest():

choice = raw_input("> ")

if "hello" or "world" in choice:
print "There is hello or world in 'choice'"
elif "bye" or "cya" in choice:
print "There is bye or cya in 'choice'"
else:
print "Go again"
return intest()

intest()


When run, no matter what is typed in the raw_input, the first if-statement is the one that executes. What is the problem?


Aucun commentaire:

Enregistrer un commentaire