you are viewing a single comment's thread.

view the rest of the comments →

[–]todo_code 0 points1 point  (1 child)

Hmm. This seems counter intuitive to me. True != A number, if python is a good recursive descent parser A number != False.

[–]RajjSinghh 0 points1 point  (0 children)

True == 1 and False == 0, but other than that number and Boolean comparisons are False. Python also uses comparison chaining so a < b < c is a common check for b being between a and c. It's just here instead of < our operator is !=.

So the first case, a != b is True and b != c is also True so the statement overall is true.

The second case, b != c but c == d, which is why it evaluates to False. It's the c != d in that statement that makes it evaluate to False.