SiteMap  | About    

Ternary Operator in Python

Ternary operators are more commonly known as conditional expressions in Python that evaluate something based on a condition being true or not. It simply allows to test a condition in a single line replacing the multiline if-else making the code compact.

Syntax :

This basically reads as follows: The result will be True if the expression true, otherwise the result is False .

Same as

Ternary operator allows to quickly test a condition instead of a multiline if statement. Often times it can be immensely helpful and can make your code compact but still maintainable. (C) 2018    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.