ACTIVITY 43 / 50
Try as many times as you needTwo independent robots
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 objectsCreate 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
- Read the last line of the error message.
- Find the indicated line. Check quotes, parentheses and indentation.
- Change one thing and run again.
main.py
4 spaces
Your draft stays in this browser.
Result
PythonYour program’s output will appear here. Click Run.
Мой профиль