2026-03-23
last update: 2026-09-05
The Python Ternary Operator
My most recent Python dicovery is the ternary operator.
The ternary operator returns one of two values, based on the truthiness of a Boolean expression.
Here's an example without the ternary operator, using an if-statement.
return
return
Here's the same function, using the ternary operator.
return
Smart and succinct!