Chemi Chemi - 1 month ago 5
Python Question

Python: Shorter way of checking if a string equals two other strings

have just started learning python and this question came up to my mind
is there a shorter way to determine if a string equals 'something' or 'somethingelse'?


input = raw_input("question?")

while input != 'n' and input != 'y':
#ask question again


You could check whether it is in a list or set.

input = raw_input("question?")

while input not in ['n', 'N']:
    #ask question again

If you are just trying to accept two cases though, you could also just call lower on the input.

while input.lower() != 'n':
    #ask question again