Мой профиль
ACTIVITY 24 / 50

Project: robot route

Try as many times as you need

Let’s understand

Combine input, a loop and conditions. A robot receives an energy amount followed by three commands. MOVE uses two units if enough energy remains. Any other command leaves the amount unchanged. Report the remaining energy after each command. Process all three commands in order, even if energy runs out.

Listen to the explanation

Example

for turn in range(2):
    command = input()
    if command == "LOOK":
        print("Looking")
YOUR MISSION

Read integer energy. Then read three commands. For MOVE with energy >= 2, subtract 2. Print energy after each command.

I need a hint

Use for with range(3). Read a command, check both conditions with and, then print the remaining energy.

How to find an error
  1. Read the last line of the error message.
  2. Find the indicated line. Check quotes, parentheses and indentation.
  3. Change one thing and run again.

main.py

4 spaces

Your draft stays in this browser.

Result

Python
Your program’s output will appear here. Click Run.