Can we compare one value with multiple values using 'or'?



When comparing one value with multiple values, can we just separate each value with or?


No, when comparing one value with many other values, or cannot be used to check, for instance, if “a value equals some value or another value or another value.” Each side of the or must be a valid expression on their own, so this would not work.


# This would not compare value with 10, 11, 12.
if (value == 10 or 11 or 12):
  print("Fourth quarter")

# Instead, each comparison must be separate and 
# valid on their own on each side of each "or".
if (value == 10 or value == 11 or value == 12):
  print("Fourth quarter")