If we have multiple if
statements, we can use the if-elif-else
statement. This allows us to add more conditions. For the positive-negative-zero number example above, the Python code can be written as,
xxxxxxxxxx
x = 5
if x > 0:
print ("x is positive")
elif x < 0:
print ("x is negative")
else:
print("x is zero")
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment