if x == y != z:
print (x + y)
Yes as is stated in the documentation:
Comparisons can be chained arbitrarily, e.g.,
x < y <= zis equivalent to
x < y and y <= z, except that
yis evaluated only once (but in both cases
zis not evaluated at all when
x < yis found to be false).
So you can chain any kind of comparator:
is [not], and
The documentation further makes it more formal:
Formally, if a, b, c, ..., y, z are expressions and op1, op2, ..., opN are comparison operators, then
a op1 b op2 c ... y opN zis equivalent to
a op1 b and b op2 c and ... y opN z, except that each expression is evaluated at most once.
So for instance:
'a' in 'ab' in 'zabc'
is equivalent to:
'a' in 'ab' and 'ab' in 'zabc'