Table of Contents
Hide
- Python TypeError: ‘list’ object is not callable
- Scenario 1 – Using the built-in name list as a variable name
- Solution for using the built-in name list as a variable name
- Scenario 2 – Indexing list using parenthesis()
- Solution for Indexing list using parenthesis()
- Conclusion
The most common scenario where Python throws TypeError: ‘list’ object is not callable is when you have assigned a variable name as “list” or if you are trying to index the elements of the list using parenthesis instead of square brackets.
In this tutorial, we will learn what ‘list’ object is is not callable error means and how to resolve this TypeError in your program with examples.
There are two main scenarios where you get a ‘list’ object is not callable error in Python. Let us take a look at both scenarios with examples.
Scenario 1 – Using the built-in name list as a variable name
The most common mistake the developers tend to perform is declaring the Python built-in names or methods as variable names.
What is a built-in name?
In Python, a built-in name is nothing but the name that the Python interpreter already has assigned a predefined value. The value can be either a function or class object.
The Python interpreter has 70+ functions and types built into it that are always available.
In Python, a list is a built-in function, and it is not recommended to use the built-in functions or keywords as variable names.
Python will not stop you from using the built-in names as variable names, but if you do so, it will lose its property of being a function and act as a standard variable.
Let us take a look at a simple example to demonstrate the same.
fruit = "Apple"
list = list(fruit)
print(list)
car="Ford"
car_list=list(car)
print(car_list)
Output
['A', 'p', 'p', 'l', 'e']
Traceback (most recent call last):
File "c:PersonalIJSCodemain.py", line 6, in <module>
car_list=list(car)
TypeError: 'list' object is not callable
If you look at the above example, we have declared a fruit variable, and we are converting that into a list and storing that in a new variable called “list“.
Since we have used the “list” as a variable name here, the list() method will lose its properties and functionality and act like a normal variable.
We then declare a new variable called “car“, and when we try to convert that into a list by creating a list, we get TypeError: ‘list’ object is not callable error message.
The reason for TypeError is straightforward we have a list variable that is not a built function anymore as we re-assigned the built-in name list in the script. This means you can no longer use the predefined list value, which is a class object representing the Python list.
Solution for using the built-in name list as a variable name
If you are getting object is not callable error, that means you are simply using the built-in name as a variable in your code.
fruit = "Apple"
fruit_list = list(fruit)
print(fruit_list)
car="Ford"
car_list=list(car)
print(car_list)
Output
['A', 'p', 'p', 'l', 'e']
['F', 'o', 'r', 'd']
In our above code, the fix is simple we need to rename the variable “list” to “fruit_list”, as shown below, which will fix the ‘list’ object is not callable error.
Scenario 2 – Indexing list using parenthesis()
Another common cause for this error is if you are attempting to index a list of elements using parenthesis() instead of square brackets []. The elements of a list are accessed using the square brackets with index number to get that particular element.
Let us take a look at a simple example to reproduce this scenario.
my_list = [1, 2, 3, 4, 5, 6]
first_element= my_list(0)
print(" The first element in the list is", first_element)
Output
Traceback (most recent call last):
File "c:PersonalIJSCodetempCodeRunnerFile.py", line 2, in <module>
first_element= my_list(0)
TypeError: 'list' object is not callable
In the above program, we have a “my_list” list of numbers, and we are accessing the first element by indexing the list using parenthesis first_element= my_list(0), which is wrong. The Python interpreter will raise TypeError: ‘list’ object is not callable error.
Solution for Indexing list using parenthesis()
The correct way to index an element of the list is using square brackets. We can solve the ‘list’ object is not callable error by replacing the parenthesis () with square brackets [] to solve the error as shown below.
my_list = [1, 2, 3, 4, 5, 6]
first_element= my_list[0]
print(" The first element in the list is", first_element)
Output
The first element in the list is 1
Conclusion
The TypeError: ‘list’ object is not callable error is raised in two scenarios

- If you try to access elements of the list using parenthesis instead of square brackets
- If you try to use built-in names such as list as a variable name
Most developers make this common mistake while indexing the elements of the list or using the built-in names as variable names. PEP8 – the official Python style guide – includes many recommendations on naming variables properly, which can help beginners.
Before you can fully understand what the error means and how to solve, it is important to understand what a built-in name is in Python.
What is a built-in name?
In Python, a built-in name is a name that the Python interpreter already has assigned a predefined value. The value can be either a function or class object. These names are always made available by default, no matter the scope. Some of the values assigned to these names represent fundamental types of the Python language, while others are simple useful.
As of the latest version of Python — 3.6.2 — there are currently 61 built-in names. A full list of the names and how they should be used, can be found in the documentation section Built-in Functions.
An important point to note however, is that Python will not stop you from re-assigning builtin names. Built-in names are not reserved, and Python allows them to be used as variable names as well.
Here is an example using the dict built-in:
>>> dict = {}
>>> dict
{}
>>>
As you can see, Python allowed us to assign the dict name, to reference a dictionary object.
What does «TypeError: ‘list’ object is not callable» mean?
To put it simply, the reason the error is occurring is because you re-assigned the builtin name list in the script:
list = [1, 2, 3, 4, 5]
When you did this, you overwrote the predefined value of the built-in name. This means you can no longer use the predefined value of list, which is a class object representing Python list.
Thus, when you tried to use the list class to create a new list from a range object:
myrange = list(range(1, 10))
Python raised an error. The reason the error says «‘list’ object is not callable», is because as said above, the name list was referring to a list object. So the above would be the equivalent of doing:
[1, 2, 3, 4, 5](range(1, 10))
Which of course makes no sense. You cannot call a list object.
How can I fix the error?
Suppose you have code such as the following:
list = [1, 2, 3, 4, 5]
myrange = list(range(1, 10))
for number in list:
if number in myrange:
print(number, 'is between 1 and 10')
Running the above code produces the following error:
Traceback (most recent call last):
File "python", line 2, in <module>
TypeError: 'list' object is not callable
If you are getting a similar error such as the one above saying an «object is not callable», chances are you used a builtin name as a variable in your code. In this case and other cases the fix is as simple as renaming the offending variable. For example, to fix the above code, we could rename our list variable to ints:
ints = [1, 2, 3, 4, 5] # Rename "list" to "ints"
myrange = list(range(1, 10))
for number in ints: # Renamed "list" to "ints"
if number in myrange:
print(number, 'is between 1 and 10')
PEP8 — the official Python style guide — includes many recommendations on naming variables.
This is a very common error new and old Python users make. This is why it’s important to always avoid using built-in names as variables such as str, dict, list, range, etc.
Many linters and IDEs will warn you when you attempt to use a built-in name as a variable. If your frequently make this mistake, it may be worth your time to invest in one of these programs.
I didn’t rename a built-in name, but I’m still getting «TypeError: ‘list’ object is not callable». What gives?
Another common cause for the above error is attempting to index a list using parenthesis (()) rather than square brackets ([]). For example:
>>> lst = [1, 2]
>>> lst(0)
Traceback (most recent call last):
File "<pyshell#32>", line 1, in <module>
lst(0)
TypeError: 'list' object is not callable
For an explanation of the full problem and what can be done to fix it, see TypeError: ‘list’ object is not callable while trying to access a list.
Have you ever seen the TypeError object is not callable when running one of your Python programs? We will find out together why it occurs.
The TypeError object is not callable is raised by the Python interpreter when an object that is not callable gets called using parentheses. This can occur, for example, if by mistake you try to access elements of a list by using parentheses instead of square brackets.
I will show you some scenarios where this exception occurs and also what you have to do to fix this error.
Let’s find the error!
What Does Object is Not Callable Mean?
To understand what “object is not callable” means we first have understand what is a callable in Python.
As the word callable says, a callable object is an object that can be called. To verify if an object is callable you can use the callable() built-in function and pass an object to it. If this function returns True the object is callable, if it returns False the object is not callable.
callable(object)
Let’s test this function with few Python objects…
Lists are not callable
>>> numbers = [1, 2, 3]
>>> callable(numbers)
False
Tuples are not callable
>>> numbers = (1, 2, 3)
>>> callable(numbers)
False
Lambdas are callable
>>> callable(lambda x: x+1)
True
Functions are callable
>>> def calculate_sum(x, y):
... return x+y
...
>>> callable(calculate_sum)
True
A pattern is becoming obvious, functions are callable objects while data types are not. And this makes sense considering that we “call” functions in our code all the time.
What Does TypeError: ‘int’ object is not callable Mean?
In the same way we have done before, let’s verify if integers are callable by using the callable() built-in function.
>>> number = 10
>>> callable(number)
False
As expected integers are not callable 🙂
So, in what kind of scenario can this error occur with integers?
Create a class called Person. This class has a single integer attribute called age.
class Person:
def __init__(self, age):
self.age = age
Now, create an object of type Person:
john = Person(25)
Below you can see the only attribute of the object:
print(john.__dict__)
{'age': 25}
Let’s say we want to access the value of John’s age.
For some reason the class does not provide a getter so we try to access the age attribute.
>>> print(john.age())
Traceback (most recent call last):
File "callable.py", line 6, in <module>
print(john.age())
TypeError: 'int' object is not callable
The Python interpreter raises the TypeError exception object is not callable.
Can you see why?
That’s because we have tried to access the age attribute with parentheses.
The TypeError‘int’ object is not callable occurs when in the code you try to access an integer by using parentheses. Parentheses can only be used with callable objects like functions.
What Does TypeError: ‘float’ object is not callable Mean?
The Python math library allows to retrieve the value of Pi by using the constant math.pi.
I want to write a simple if else statement that verifies if a number is smaller or bigger than Pi.
import math
number = float(input("Please insert a number: "))
if number < math.pi():
print("The number is smaller than Pi")
else:
print("The number is bigger than Pi")
Let’s execute the program:
Please insert a number: 4
Traceback (most recent call last):
File "callable.py", line 12, in <module>
if number < math.pi():
TypeError: 'float' object is not callable
Interesting, something in the if condition is causing the error ‘float’ object is not callable.
Why?!?
That’s because math.pi is a float and to access it we don’t need parentheses. Parentheses are only required for callable objects and float objects are not callable.
>>> callable(4.0)
False
The TypeError‘float’ object is not callable is raised by the Python interpreter if you access a float number with parentheses. Parentheses can only be used with callable objects.
What is the Meaning of TypeError: ‘str’ object is not callable?
The Python sys module allows to get the version of your Python interpreter.
Let’s see how…
>>> import sys
>>> print(sys.version())
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
No way, theobject is not callable error again!
Why?
To understand why check the official Python documentation for sys.version.

That’s why!
We have added parentheses at the end of sys.version but this object is a string and a string is not callable.
>>> callable("Python")
False
The TypeError‘str’ object is not callable occurs when you access a string by using parentheses. Parentheses are only applicable to callable objects like functions.
Error ‘list’ object is not callable when working with a List
Define the following list of cities:
>>> cities = ['Paris', 'Rome', 'Warsaw', 'New York']
Now access the first element in this list:
>>> print(cities(0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable
What happened?!?
By mistake I have used parentheses to access the first element of the list.
To access an element of a list the name of the list has to be followed by square brackets. Within square brackets you specify the index of the element to access.
So, the problem here is that instead of using square brackets I have used parentheses.
Let’s fix our code:
>>> print(cities[0])
Paris
Nice, it works fine now.
The TypeError‘list’ object is not callable occurs when you access an item of a list by using parentheses. Parentheses are only applicable to callable objects like functions. To access elements in a list you have to use square brackets instead.
Error ‘list’ object is not callable with a List Comprehension
When working with list comprehensions you might have also seen the “object is not callable” error.
This is a potential scenario when this could happen.
I have created a list of lists variable called matrix and I want to double every number in the matrix.
>>> matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
>>> [[2*row(index) for index in range(len(row))] for row in matrix]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <listcomp>
File "<stdin>", line 1, in <listcomp>
TypeError: 'list' object is not callable
This error is more difficult to spot when working with list comprehensions as opposed as when working with lists.
That’s because a list comprehension is written on a single line and includes multiple parentheses and square brackets.
If you look at the code closely you will notice that the issue is caused by the fact that in row(index) we are using parentheses instead of square brackets.
This is the correct code:
>>> [[2*row[index] for index in range(len(row))] for row in matrix]
[[2, 4, 6], [8, 10, 12], [14, 16, 18]]
Conclusion
Now that we went through few scenarios in which the errorobject is not callable can occur you should be able to fix it quickly if it occurs in your programs.
I hope this article has helped you save some time! 🙂
Related posts:

I’m a Tech Lead, Software Engineer and Programming Coach. I want to help you in your journey to become a Super Developer!