I'm learning about comparison operators, and I was playing around with True and False statements. I ran the following code in the Python shell:
not(5>7) == True
As expected, this returned True
. However, I then ran the following code:
True == not(5>7)
and there was a syntax error. Why was this? If the first line of code is valid syntax, then surely the second line of code should also be valid. Where have I gone wrong?
(To give a bit of background, my understanding is that =
in Python is only used for variable assignment, while ==
is closely related to the mathematical symbol '='.)