chained comparison

Writing several comparisons in a row, as in 0 <= x < 10, which means 0 <= x and x < 10.

In more detail

Each middle value is evaluated once. It is clearer than joining the two tests with and, but x == 1 or 2 is not a chain: it is always true, because 2 on its own is truthy.

Related terms

Taught in

References

Certification courses