- The ternary operator is defined as the operator that evaluates the conditions to find the final result.
- It evaluates more than one expression.
- A single line code is written according to the condition.
- There is another syntax for the ternary operator when there are more than 2 conditions i.e;
- syntax: x= first value if condition 1 else second value if condition 2 else third value.
- In the ternary operator, we can perform a nested loop also.
- We can reduce the length of the code by using this ternary operator, in this operator we write a code in a single line.
- So time is saved and less complexity in the code.
#write a python program for integers using the ternary operator.
- max= b if b>a else a.