-2

Is there a way for python to check multiple values for "not equals to"? Like:

if len(dict) != 2 or 4 or 8 or 16 or 32:
    do_something()
J. Doe
  • 19
  • 3

1 Answers1

0

Use a set:

if len(dict) not in {2, 4, 8, 16, 32}:
    do_something()
dhuang
  • 909
  • 4
  • 18