Name

else

Examples
for i in range(5, 95, 5): 
 if i < 35:
 line(30, i, 80, i)
 else:
 line(20, i, 90, i)
for i in range(5, 95, 5): 
 if i < 35:
 line(30, i, 80, i)
 elif i < 65:
 line(20, i, 90, i)
 else:
 line(0, i, 100, i)
Description Extends the if structure allowing the program to choose between two or more blocks of code. It specifies a block of code to execute when the expression in if is False.
Syntax
if expression:
 statements 
else:
 statements 
if expression:
 statements 
elif expression:
 statements 
else:
 statements 
Parameters
expressionany valid expression that evaluates to true or false
statementsone or more statements to be executed
Related if
if

Updated on Tue Feb 27 14:07:12 2024.

If you see any errors or have comments, please let us know.

Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License

AltStyle によって変換されたページ (->オリジナル) /