By using the ternary operator, conditional branching of assignment can be described smartly in one line.
python
if n == 10:
x = "OK"
else :
x = "NG"
This can be expressed in one line using the ternary operator as follows.
python
x = "OK" if n == 10 else "NG"
Recommended Posts