![]() ![]() |
Conceptual Review (page 24 of 55) |
Python also supports the if-else statement for alternative execution. In the example in the below figure, there are two possibilities. The initial Boolean expression in the "if" clause determines which one gets executed.
The "if" section is fired and executes for the True condition while the "else" section is executed for the False condition. If the value contained in the days variable equals 31, then python will print the "You passed the test" message. Otherwise, python will jump to the else clause and print the "You failed the test" message.
Notice that both the if and else sections end with a ":" and the statements beneath them are indented.
