Find Mistake: Missing self Parameter
Find the Mistake Medium
Question
This code raises a TypeError. What is wrong?
Code
class Counter:
def increment():
pass
Hint
Methods need a special first parameter.
Explanation
Instance methods must have self as the first parameter. The fix is def increment(self):. When you call obj.increment(), Python passes obj as the first argument, so the method needs a parameter to receive it.
Related Resources
Related Lessons
- Classes and Objects
The self parameter.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.