Ternary Operator¶
Ternary operator (?:
) has a condition and two values that is evaluated as per the truthiness of the condition.
Syntax
condition ? trueExpr : falseExpr
Example
1 > 2 ? "Yes!" : "No!"
# No!
4 < 2 ? 2 : 4
# 4