Sorry, don't really know how to phrase the question so it may seem ambiguous.
What I'd like to do is essentially I have a code that reads the input from a user and compares it to certain letters but this process should be case non-sensitive. So I use the .lower() string method.
if (letter.lower() == "a" or letter.lower() == "b" or letter.lower() == "c"):
(In this case, the values "A", "B", "C", "a", "b" and "c" should be accepted and all other values assigned to the name "letter" rejected.)
Can this be shortened any further? Readability isn't that important unless it is truly gobbledygook that cannot be understood by human tongue haha.
I tried:
if (letter.lower() == "a" or "b" or "c"):
which doesn't work. Neither does:
if (letter.lower() == ("a" or "b" or "c")):
I appreciate any input. Thanks in advance :)
Aucun commentaire:
Enregistrer un commentaire