mardi 27 août 2019

python conditional one or the other but not both and print the True one

So I'm trying to make an if statement to check two variables if they're > 10 if both of them are True, I want the code to pass or stop. But if one of them is True, I want the code to print that one True variable.

For example:

var1 = 5
var2 = 11

if (var1 >= 10) is not (var2 >= 10):
    # print the true variable
else:
    pass

In this case, I want it to print:

var2 = 11

but if var1 is the True variable, I want it to print var1 instead. Any answer would be appreciated.

Aucun commentaire:

Enregistrer un commentaire