The ternary operator is very useful for a single condition. But support ternary operator different way, not like other programming languages (
Syntax: A if C else B
This first evaluates C; if it is true, A is evaluated to give the result, otherwise, B is evaluated to give the result.
>>> 'true' if True else 'false' 'true' >>> 'true' if False else 'false' 'false'
Also Read : Python Interview Question