Write better Python code by using comparison operator chaining (a < b < c)

Tremaine Eto
Towards Dev
Published in
3 min readNov 28, 2022

--

Photo by Artturi Jalli on Unsplash.

If you’ve programmed before, then you’ve likely used a combination of comparisons in conditions. I’m talking things like:

if a == "hi" && b == "hi" {   ...}

and

if a < 3 && b < 5 {  ...

--

--

Senior Software Engineer @ Iterable | Previously worked at DIRECTV, AT&T, and Tinder | UCLA Computer Science alumni | Follow me for software engineering tips!