Putting a simple if-then-else statement on one line
In Python, you can put a simple if-then-else statement on one line using the ternary operator, which is represented by the "?" symbol. The general format is:
Watch a video course
Python - The Practical Guide
For example:
This will print "x is greater than 3" to the console, because the condition (x > 3) is true.