Why is ‘True == not False’ a SyntaxError?

It has to do with operator precedence in Python (the interpreter thinks you’re comparing True to not, since == has a higher precedence than not). You need some parentheses to clarify the order of operations:

True == (not False)

In general, you can’t use not on the right side of a comparison without parentheses. However, I can’t think of a situation in which you’d ever need to use a not on the right side of a comparison.

Leave a Comment