This question already has an answer here:
In Python when I want to check multiple values a variable could be, it usually looks something like this:
if (a == 1 or a == 2 or a == 3):
I have seen the range() function used with if statements, but I want this to work even for strings. Example:
if (a == 'a' or a == 'b' or a == 'c'):
Is there any way to shorthand these so they are not so long?
Aucun commentaire:
Enregistrer un commentaire