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.
This basically reads as follows: The result will be True if the expression true, otherwise the result is False .
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.