June 2017
Beginner
352 pages
8h 39m
English
The if-statement supports an optional else clause which goes in a block introduced by the else keyword (followed by a colon) which is indented to the same level as the if keyword. Let's start by creating (but not finishing) an if-block:
>>> h = 42>>> if h > 50:... print("Greater than 50")
To start the else block in this case, we just omit the indentation after the three dots:
... else:... print("50 or smaller")...50 or smaller
Read now
Unlock full access