Python Flow control

else if

value = True
if not value:
    print("Value is False")
elif value is None:
    print("Value is None")
else:
    print("Value is True")

One line

>>> a = 330
>>> b = 200
>>> r = "a" if a > b else "b"
>>> print(r)
a

Basic

num = 5
if num > 10:
    print("num is totally bigger than 10.")
elif num < 10:
    print("num is smaller than 10.")
else:
    print("num is indeed 10.")
Comments