Python ternary operator [duplicate]

PEP 308 adds a ternary operator:

foo = "True" if test else "False"

It’s been implemented since Python 2.5

Leave a Comment