How can I make Python quit if a list contains a particular word?
text = input("Input text: ")
if["exit","quit","close"] in text:
Quit()
How can I make Python quit if a list contains a particular word?
text = input("Input text: ")
if["exit","quit","close"] in text:
Quit()
It's the other way around
if text in ["exit","quit","close"]:
You can read it as pseudo English, you are checking if the string is in the list.
If you want to check if part of the input is in the list you can use any
if any(x in ["exit", "quit", "close"] for x in text.split(' ')):
You've got it backwards. Try
if text in ["...","..."]:
Think of it as "If this is in that".