2

I'm curious, why in python this expression produces False:

>>> False == True != True
False

For comparsion, js:

> false == true != true
true

golang:

fmt.Println(false == true != true) => true

And I can explain why js and golang have such results: if you compute this expression from left to right, you will get false != true, which is true. How does python interpret this code to get False?

Ilya Boltnev
  • 1,031
  • 3
  • 13
  • 27
  • The weird thing is that `False != True != True` also returns `False`. – Farhood ET Mar 31 '19 at 08:51
  • Dupe helps, just note that `==` and `!=` have the same operator precedence as `is`. https://docs.python.org/3/reference/expressions.html#comparisons – TrebledJ Mar 31 '19 at 08:52
  • Maybe python can't interpret 3 T/F statements in a row. False == (True != True) returns True – Doğuş Mar 31 '19 at 09:16

0 Answers0