Python: if then else
if
x = 1 if x == 1: print("yes")
if else
y = 2 if y == 1: print("yes") else: print("no")
if else chain
Note it's elif
:
z = 2 if z < 0: print("neg") elif z == 0: print("zero") elif z == 1: print("one") else: print("other")
x = 1 if x == 1: print("yes")
y = 2 if y == 1: print("yes") else: print("no")
Note it's elif
:
z = 2 if z < 0: print("neg") elif z == 0: print("zero") elif z == 1: print("one") else: print("other")