I want to implement something conceptually like the following:
if condition1:
action1()
also if condition2:
action2()
also if condition3:
action3()
also if condition4:
action4()
also if condition5:
action5()
also if condition6:
action6()
else:
print("None of the conditions was met.")
What would be a reasonable and clear way of implementing logic like this? How could an else
be bound to multiple if
statements? Would I be forced to create a boolean to keep track of things?
I would suggest:
if condition1:
action1()
if condition2:
action2()
...
if not any(condition1, condition2, ...):
print(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With