This question already has an answer here:
This is the script that is working:
proceed = True
while proceed:
#part of code that is not involved in the question
again = raw_input("Would you like to calculate again? yes/no? ")
if again != "yes":
proceed = False
print "Bye"
print "If you didn't want to quit input 'yes'... "
However I would like my code to be like this:
# not working don't know why:
if again != "yes" or "Yes" or "Y" or "y":
proceed = False
print "Bye"
Here it becomes fustrating, because when the interactive program asks me if i want to do it again, and i type Y, it proceeds with a bye and kicks me out of the interactive program.
Why doesn't this work in an if statement? Are there to many conditions?
I don't want to use if again == "yes" or etc., because then i have to use another else statement, which is less efficient.
I just simply want to know why the multiple "or" statements do not work here ;)
Aucun commentaire:
Enregistrer un commentaire