How to write ternary operator in Python?

The ternary operator was introduced in Python from version 2.5. You can write ternary operator in Python using below syntax –

Here is a simple example of ternary operator in Python –

Leave a Reply