How to write a simple if/else statement in one line using Python. This is commonly know as a ternary operator in many programming languages. In Python, I find that a single line if/else statement is easier to read and understand than in most languages.