Does Python have a ternary (?:) operator? Conditional expressions in Python, and when to use them

Published: 26 August 2020
on channel: Python and Pandas with Reuven Lerner
1,521
55

Many languages have a "ternary operator," allowing you to express a condition and an expression in a short form. In this video, I answer a question from a subscriber to my "Better developers" newsletter (https://BetterDevelopersWeekly.com/), in which he says that you can have conditions in lambdas in this way. My response? You're right, but it's so unreadable, do you want to?