Ternary Operator in Python

Last updated 1 year, 4 months ago | 535 views 75     5

Tags:- Python

Python | Ternary Operator

python uses an if-else conditional statement in a single line to represent the Ternary Operator.

[true] if [expression] else [false]

Let's see an example of Ternary Operator

a, b = 10, 20
max = a if a > b else b 

The above program is showing an example of finding the max number among two numbers using the Ternary operator.