How to layer if statements when order of logic is irrelevant?
- by jimmyjimmy
Basically I have a series of logic in my website that can lead to 5 total outcomes. Basically two different if tests and then a catch all else statement.
For example:
if cond1:
if mod1:
#do things
elif mod2:
#do things
elif cond2:
if mod1:
#do things
elif mod2
#do things
else:
#do things
I was thinking about rewriting it like this:
if cond1 and mod1:
#do things
elif cond1 and mod2:
#do things
elif cond2 and mod1:
#do things
elif cond2 and mod2:
#do things
else:
#do things
Is there any real difference in these two coding options/a better choice for this kind of logic testing?