Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace multiple == checks with in #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/demo_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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?")


Expand Down
2 changes: 1 addition & 1 deletion python/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading