0

I'm trying to make a program where if the user enters 'q' or 'quit' or 'Quit' the loop will break. I figured out how to do half of the problem but I've been stuck for over an hour with the rest.

text = ()
while text != 'q' or 'quit' or 'Quit':
    print((text)[::-1])
    text = input()

The code above won't end the loop when typing any of the keywords, but if i do only: while text != 'q' that works. How can I add the other two? Thank you.

Alex
  • 49
  • 3
  • See that link on why your "multiple" attempt didn't work. Also, you need `and`, not `or`. You want to ensure that they *all* hold, not that any one of them is true. You could also reconfigure it using [De Morgan's Laws](https://en.wikipedia.org/wiki/De_Morgan%27s_laws). – Carcigenicate Oct 09 '20 at 23:47

1 Answers1

0

use in as in the following :

text = ()
while text not in ('q', 'quit', 'Quit'):
    print((text)[::-1])
    text = input()
Pixel_teK
  • 793
  • 5
  • 16