What is the explanation for this behavior in Python?
a = 10 b = 20 a and b # 20 b and a # 10
a and b evaluates to 20, while
a and b
See the docs:
x and y if x is false, then x, else y
non-zero integers are treated as boolean true, so you get exactly the behavior described in the docs:
>>> a = 10 >>> b = 20 >>> a and b 20 >>> b and a 10