Argo, the vacuum cleaner

Task 1: Cleanup

(a) Complete the solution below so that all power-ups are collected in World 1.
(b)
Click on World 2 (see right) and start the program.
An error message appears:
Collision with an asteroid! Check line 7. (Kollision mit einem Asteroiden! Prüfe Zeile 7.
)
Find the error in the program and correct it.
💡 Tip for part (b)
Activate debug mode.
Examine which lines are executed when the Argo is on the last power-up of the first level.
💡 No idea yet?
3 if onPow():
4 removePow()
5 move()
6 if not onPow():
7 move()



Argo runs into a wall in line 7 because it moves twice: Both if statements are executed (line 3 and line 6).
Use an if-else-construct to change this.
💡 Still no idea?
Change the code as shown in the flowchart: