0
phoneMinutes = int(input("Please enter your desired call minutes."))
if phoneMinutes != 100 or 200 or 300: 
    print("false")

else:
    print("true")

I am trying to make this program output "true" if the variable phoneMinutes is equal to either 100, 200 or 300, other-wise it will print "false". However, as soon as I start using or statements, every time I run the program, the output is "false". Not quite sure what's going wrong here so any suggestions would be welcome.

1 Answers1

0

if phoneMinutes != 100 or 200 or 300: This isn't correct syntax; this works like if (phoneMinutes != 100) or (200) or (300). 200 is a truthy value, so it will always be true. You want if phoneMinitues != 100 or phoneMinutes != 200 or phoneMinutes != 300: as a quick and dirty way of doing it.

clubby789
  • 2,543
  • 4
  • 16
  • 32
  • @OliverMinter-King or the more compact way of doing it: `if phoneMinutes in (100, 200, 300): print("true")` – Tomerikoo Sep 17 '20 at 11:38