Is there a simple way to test 2 variables with 3 conditions or 3 variables with 7 conditions and so on?
def checkXYZ():
if x==1 and y==0 and z==0:
doX()
elif x==0 and y==1 and z==0:
doY()
elif x==0 and y==0 and z==1:
doZ()
elif x==1 and y==1 and z==0:
doXY()
elif x==0 and y==1 and z==1:
doYZ()
elif x==1 and y==0 and z==1:
doXZ()
elif x==1 and y==1 and z==1:
doXYZ()
Aucun commentaire:
Enregistrer un commentaire