Where do I put common code for if and elif?
- by Vishal
For the example below:
if a == 100:
# Five lines of code
elif a == 200:
# Five lines of code
Five lines of code is common and repeating how can I avoid it?
I know about putting it a function
or
if a == 100 or a == 200:
# Five lines of code
if a == 100:
# Do something
elif a == 200:
# Do something
Any other cleaner solution?