Anyone Can Code.
The else statement is used to give the program a case in which none of the
conditions have been met.
It must succeed if and elif statements because the input has to fail
the required conditions (i.e. the previous conditions return False) before
following the code in the 'else' subsection.
z = 20 if z == 19: print('z is equal to 19') else: print('z is not equal to 19')z is not equal to 19
x = 10 if x > 10: print('x is greater than 10') elif x < 10: print('x is less than 10') else: print('x is equal to 10') #if the input isn;t greater than or less than 10, it has to be 10x is equal to 10
That's it for this tutorial! Click Next to access the next tutorial!
This site uses cookies to improve your experience as well as for site metrics. To see more, check out our Privacy Policy