Does Ternary Operator available in Python

Spread the love

Yes, Ternary Operators are conditional operator, it evaluate condition, if it’s true it return one value or another value. It’s added in python 2.5 version onwards.

#Example program on python ternary operator

[true] if [expression] else [false]

#heighest high comparision a_height = 5.3 b_height = 5.6 result = b_height if b_height> a_height else a_height print(result)



If you have any alternative methods or procedures for same requirement, you can comment below.



Leave a Reply

Your email address will not be published. Required fields are marked *