Python TypeError: missing 1 required positional argument
A plain-words explanation of this Python message: what it means, the usual causes, and the steps that fix it.
The messageTypeError: add() missing 1 required positional argument: 'b'
Make the error yourself
Run with Python 3.14.10. This is the smallest example we could find that shows it.
Python program (main.py)
def add(a, b):
return a + b
print(add(5))Output (the real message)
Traceback (most recent call last):
File "main.py", line 4, in <module>
print(add(5))
~~~^^^
TypeError: add() missing 1 required positional argument: 'b'Why it happens
The function was defined with two parameters, a and b, but called with one value. Python names the missing parameter. In classes, the same message with self ("missing 1 required positional argument: 'self'") usually means you called a method on the class instead of on an object, such as Dog.bark() instead of Dog().bark().
How to fix it
- Give every parameter a value when you call the function, or give the parameter a default value in the definition (
b=0). - Count the commas in the call and in the definition.
- If the missing name is
self, create an object first:dog = Dog()and calldog.bark().
The corrected version
Python program (main.py)
def add(a, b=0):
return a + b
print(add(5))
print(add(5, 3))Output (the corrected version)
5
8How to avoid it
Use default values for optional parameters, and call with names (add(a=5, b=3)) when there are many.
Questions
And "takes 1 positional argument but 2 were given"?
That is the opposite problem: too many arguments, or a method defined without self.
This is an independent guide. It is not connected with Python, Microsoft, Google, GitHub or the Git project. Product names belong to their owners. Examples were run on 13 November 2026 in a practice folder or a blank workbook; your version may word a message slightly differently.