Search code examples
pythontry-catchgoogle-colaboratorydifferencexor

Why does XOR not produce the expected result


3**2==9 ^ 3-2==4 

False

True ^ False

TRUE

Why is the result of first line False while it should be True?


Solution

  • Because the operator ^ has more priority than == and the operation 9 ^ 3 has priority