Yes, Python has a ternary conditional operator, which is a shorthand way of writing an if-else statement. The syntax for a ternary conditional operator in Python is:
[on_true] if [expression] else [on_false]
For example, the following code:
x = 10 y = 20 max = x if x > y else y
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.