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:

x = 0 if 2 == 3 else 1
print(x)

Watch a course Python - The Practical Guide

For example:

x = 5
print("x is greater than 3") if x > 3 else print("x is not greater than 3")

This will print "x is greater than 3" to the console, because the condition (x > 3) is true.