diff --git a/python/demo_code.py b/python/demo_code.py index 5e502b20..32fcf043 100644 --- a/python/demo_code.py +++ b/python/demo_code.py @@ -129,7 +129,7 @@ def bad_isinstance(initial_condition, object, other_obj, foo, bar, baz): def check(x): - if x == 1 or x == 2 or x == 3: + if x in (1, 2, 3): print("Yes") elif x != 2 or x != 3: print("also true") @@ -140,7 +140,7 @@ def check(x): elif x == 10 or x == 20 or x == 30 and x == 40: print("Sweet!") - elif x == 10 or x == 20 or x == 30: + elif x in (10, 20, 30): print("Why even?") diff --git a/python/utils.py b/python/utils.py index af8508ee..4d08046b 100644 --- a/python/utils.py +++ b/python/utils.py @@ -12,7 +12,7 @@ def is_even(x): return x % 2 == 0 def is_prime(x): - if x == 0 or x == 1: + if x in (0, 1): return False for i in range(2, x):