Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
This program should show two lines when it is hot, and a last line always. It stops with an error. Find the mistake and fix it.
Lines that belong to an if are indented by four spaces.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
The mistake. The two lines under if must be indented by four spaces, because they belong to the if. Without the spaces, Python shows IndentationError: expected an indented block.
The fix. Put four spaces before each of the two lines that belong to the if. The last line has no spaces, because it must always run.
Check. The program shows It is hot., Drink some water. and Have a nice day.
Log in to join the discussion.
Loading…