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

An object takes action

Try as many times as you need

Let’s understand

A function inside a class is a method. The first parameter of a regular instance method is self. In bot.charge(), Python supplies bot as self automatically. A method can change that object’s data.

Listen to the explanation

Example

# method: def charge(self):
YOUR MISSION

Add charge to increase self.energy by 5. Create a robot with energy 0, call charge and print its energy.

I need a hint

Indent the method inside the class, and its body one level further.

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.