vendredi 27 août 2021

Get which or-condition ist met in an if-statement, python

I have the following Pyhton if-statement:

if element1 in list[2] or element2 in list[2] or 3 in list[2]:
   do some more if-statements...
else:
   print something...

Is it possible to print (or get in some way) which of the or-conditions are met if there are any. Because there are other if-statements in the if-clause, I don't want to use three different if-statements, which would be one solution. But this will end up in nearly 12 different if-statement. I just want to log which condition is met for further analysis. I googled of course, but found nothing so for. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire