Python comparison operators

I’m a bit stuck on operator priorities. Since according to edube < and > have higher precedence levels than ==, why do we have:
print(5 < 7 == 8 > 3)
Result: False
Meanwhile,
print((5 < 7) == (8 > 3))
Result: True

Idk what edube is telling you or why, but that’s not correct. See the official documentation.

Essentially 5 < 7 == 8 > 3 means (5 < 7) and (7 == 8) and (8 > 3), not something following more traditional precedence rules.

1 Like

In case this is unclear, Python comparison operators can be chained
together. The typical use case is something like this:

 if lower_limit <= x < upper_limit:
    ... x is in range ...

which would be written lower_limit <= x and x < upper_limit in a less
concise language.

1 Like

Reference: