I recently started to learn Python.
And my friend asked me which value 3 < 5 != True
evaluates to.
As I have prior experience to javascript and c++, I answered False
. (I was able to see false in both languages)
Because, operators with same precedence (comparison
) works left to right.
So that 3 < 5
is evaluated first, which becomes True
and True != True
is False
.
I believed it was right answer.
But it turned out it wasn't.
I ran this expression on my computer and it said it's True
.
Am I missing something? or Python evaluates operators with same precedence in different way?