Python Tutorials · Python Operators
Ternary Operator
Learn all about Ternary Operator in this comprehensive tutorial.
5 min read beginner
- •The ternary operator allows you to assign one value if a condition is true, and another if it is false:
- •The ternary operator can be used instead of elif in longer if statements:
The Ternary Operator
The ternary operator allows you to assign one value if a condition is true, and another if it is false:
python
Instead of Elif:
The ternary operator can be used instead of elif in longer if statements:
python
Module quiz
Test your knowledge on this module
5 questions