Python Ternary — Tuple Syntax Hack
You may know the ternary operator x if c else y in Python which reads as “return x if c else return y“. But you may not know that you can also write the ternary operator in a shorter form as (y, x)[c]. Let’s dive into this concise way of hacking your own ternary operator! … Read more