Python Ternary operator
Short form of an if … else condition is the ternary operator, it is known as a conditional operator as well. It simply allows testing a condition in a single line replacing the multiline if … else, so it makes the code compact.
Ternary operator syntax and examples
Python Ternary operator syntax and examples
'True statement' if 'condition check' else 'False statement'
age = 16 print("Hmm, You are adult.") if age >= 18 else print("You are not adult.")
You are not adult. Process finished with exit code 0