dimanche 8 décembre 2019

Python multi-conditional if statement with action for each conditional

I want to check multiple bools and do something if they are all true, but also do something for each that is true. Essentially combining the following into one:

# I want to combine this:
if funcA() and funcB and funcC():
   #do something

#with these:
if funcA():
   #do A's something

if funcB():
   #do B's something

if funcC():
   #do C's something

All the functions above just return bools.

I'm looking for a more efficient (line wise) way of doing this.

Aucun commentaire:

Enregistrer un commentaire