dimanche 5 juillet 2020

Bitwise Operator with If Statement and comparison Operators. How does this if statement work?

a = 2
b = 1
if a == 2 | b == 1:
    print(a, b)

this won't print the values of a & b

a = 2
b = 1
if ((a == 2) | (b == 1)):
    print(a, b)

this will print the values

why so?

Aucun commentaire:

Enregistrer un commentaire