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
2 questions1
Which of the following is true about Ternary Operator?
2
What is the most common pitfall when working with Ternary Operator?
Answer all questions to submit.