TypeError: takes 1 positional argument but 2 were given
Updated
The Python error "takes 1 positional argument but 2 were given" on a method almost always means a missing self. Why Python counts one more, and the fix.
What you see
class Greeter:
def hello(name):
return f"Hello, {name}"
print(Greeter().hello("Ada"))Traceback (most recent call last):
File "/home/me/project/main.py", line 5, in <module>
print(Greeter().hello("Ada"))
~~~~~~~~~~~~~~~^^^^^^^
TypeError: Greeter.hello() takes 1 positional argument but 2 were givenWhat it means
When you call a method on an object, Python passes the object itself as the first argument. Greeter().hello("Ada") is really Greeter.hello(the_greeter, "Ada"): two arguments. hello was written with one parameter, so the object takes name and "Ada" has nowhere to go.
That is why the count is one more than you typed. The extra one is the object, which is conventionally called self.
Why it happens
- A method without
self, as in the example. - A string where a tuple was meant.
Thread(target=work, args=("ada"))passes three arguments, one per letter, because("ada")is just a string in brackets. A one-item tuple needs a comma:("ada",). - A callback that receives more than you expect. Tkinter's
bind()passes an event object to the handler;command=does not. - Plainly too many arguments for a function.
How to fix it
Add self as the first parameter of the method:
class Greeter:
def hello(self, name):
return f"Hello, {name}"
If the method does not need the object, mark it @staticmethod, and Python stops passing it:
class Greeter:
@staticmethod
def hello(name):
return f"Hello, {name}"
How each Python version words it
| Python | Prints |
|---|---|
| 3.9 | TypeError: hello() takes 1 positional argument but 2 were given |
| 3.10–3.15 | TypeError: Greeter.hello() takes 1 positional argument but 2 were given |
Run on CPython 3.9.6, 3.10.22, 3.11.17, 3.12.15, 3.13.17, 3.14.9 and 3.15.1, on October 25, 2026.
3.9 names the method as "hello()". From 3.10 the message names its class too, "Greeter.hello()", which makes the method easier to find.
Questions
Why "2 were given" when I passed one?
The object before the dot counts as the first argument. Python adds it for every call through an instance.
Is self a keyword?
No, it is a convention. Python passes the object as the first parameter whatever it is called; self is the name everyone reads.
Sources
- Tutorial: method objects, Python documentation
- Built-in functions:
staticmethod(), Python documentation - Tuples and sequences, Python tutorial
Read on October 25, 2026.