This question already has an answer here:
I often come across scenarios in Python where I need to do an if statement, except I need to test two things. Whenever I do something like...
if usersinput == 'a' or 'b':
it will break my script. Things that shouldn't pass in other if statements do, functions break, and so-forth. Is there a reason why this always happens, am I using "or" in the wrong context? Is there by any chance another way to resolve my issue using a more efficient method? Basically I need a way to do an if statement that can be True if usersinput is equal to EITHER 'a' or 'b'.
Aucun commentaire:
Enregistrer un commentaire