Is there a way to shorten this if
statement?
if i != 9 or i != 23 or i != 25 or i != 33 or i !=35:
print(i)
Is there a way to shorten this if
statement?
if i != 9 or i != 23 or i != 25 or i != 33 or i !=35:
print(i)
You can use a set and check if i is not in the set:
invalid_set = {9, 23,25, 33, 35}
if i not in invalid_set:
# all good
A set lookup if O(1)
vs O(n)
with a list, tuple etc..