Spaces in Python code are important and have meaning. In the code I gave above, two lines are indented by exactly four spaces. You need to preserve that spacing for Python to understand what is going on. i.e. Without the spaces, Python can’t tell what code is executed only under the if
clause and what code only under the else
clause.
Python was even nice enough to have given you the exact error message you needed to identify and correct the issue (“IndentationError: expected an indented block”, with even a pointer indicating the exact position of the problem). Googling such error messages will help you learn your way around.