This is the short hand name of if - else. It is also know as conditional operator. Its allow to test the condition in single line.

Syntax :-

[on_true] if [expression] else [on_false]

Example :-

a,b = 7,5
print(a) if a>b else print(b)

max = a if a>b else b
print(max)

Output :-

7

5

I hope you understand the concept of ternary operator in python. If you have any suggestion or query please do a comment.

Thank You.