Do something if string is not in variable and do something if string is in variable [duplicate]

Solution 1:

Try something like this:

# above: lowercase it, AND remove leading/trailing spaces for consistency
inp = inp.lower().strip()

if inp not in ['play', 'quit']:
    # code ...

This is more obvious and extensible. As other user mentioned above, if you use this, but it before you test for exact match with 'quit' and exact match with 'play' as this is basically the else up front.