The order of operations in Python [duplicate]

Solution 1:

This is due to comparison chaining, so this (perhaps surprisingly) simplifies to

>>> None == 0 is True
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False
>>> None == 0 and 0 is True
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
False

Some other examples

>>> 1 is 1 is 1
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
>>> 1 < 2 < 3 < 4 < 5
True
>>> 4 < 2 < 3
False
>>> multiplayer_sandwich_order = "€35"
>>> 10 < int(multiplayer_sandwich_order[1:]) < 40
True
>>> 10 < int(multiplayer_sandwich_order[1:]) < 30
False