Use in to check if something is contained in something else:
"a" in "apple" # True
"x" in "apple" # False
5 in [1, 2, 3, 4, 5] # True
"cat" in ["dog", "bird"] # False
This is cleaner than checking multiple conditions:
# Instead of:
if answer == "y" or answer == "yes" or answer == "Y":
# Use:
if answer in ["y", "yes", "Y"]:
in works with strings, lists, tuples, sets, and dictionary keys. It's one of Python's most readable features.