Chained Comparison

say it: “CHAYND kum-PAIR-ih-sun” /ˈtʃeɪnd kəmˈpærɪsən/

Several comparisons in one go, like 18 <= age < 65.

What is a chained comparison?

A chained comparison checks several comparisons in one go, the way you would write it in math.

age = 30
print(18 <= age < 65)  # True: working age

Level: Journeyman · More Python terms at this level

Updated