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

Two independent robots

Try as many times as you need

Let’s understand

Each instance holds its own data when it is created through self in __init__. Changing the first robot should not accidentally change the second. In games, each character needs its own name and state.

Listen to the explanation

Example

# one class → several objects
YOUR MISSION

Create two robots. Charge only the first. Print their energies on separate lines.

I need a hint

Use two separate calls to Robot().

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.