-1

My code is below. I want this code to print only when the input is 5 or 6 but anything I type print function works. It is probably because I use the "or" operator wrongly but I could not find any more info. for example when the input is 8, it still prints.

a = 5
b = 6
if input() == a or b :
   print("5 or 6")
  • 1
    This is a common mistake. `input() == 5 or 6` evaluates to `True` or `6`, so your check is always true in the end. You can fix this by using `if input() in (a, b)`. – LMD May 28 '22 at 10:20

0 Answers0