r/learningpython • u/Robowiko123 • Jun 26 '20
Which one is cleaner to use?
if variable.attr in (1, 2):
some_list.append(variable)or
if variable.attr == 1:
some_list.append(variable)
elif variable.attr == 2:
some_list.append(variable)The code executed inside of the if statement will always be a single line of code
2
Upvotes
View all comments
Show parent comment
1
u/Robowiko123 Jun 26 '20
Thank you for answering!