How to Resolve "TypeError: 'list' object is not callable" in Python
When programming in Python, you may encounter the TypeError: 'list' object is not callable. This error occurs when you use parentheses () on a variable that holds a list, treating it as if it were a function. In Python, the () syntax is the "call" operator, which is reserved for executing functions or methods, not for accessing elements in a data structure like a list.
The error is a clear signal that there is either a syntax mistake in how you are accessing list elements or a variable naming conflict in your code. This guide will walk you through the two most common causes of this error and show you how to resolve them.
Understanding the Error: The "Call" Operator ()
In Python, an object is "callable" if you can execute it using parentheses (). Functions and methods are callable. Data containers like lists, tuples, and dictionaries are not callable.
The TypeError: 'list' object is not callable means Python has encountered code like my_list(...) and is telling you that the variable my_list contains a list, which is just data and cannot be executed as a function.
Cause 1: Using Parentheses () Instead of Square Brackets [] for Indexing
This is the most frequent cause of the error, especially for beginners. The correct syntax for accessing an element in a list by its index is square brackets [].
Example of code causing the error:
my_list = [10, 20, 30]
# Incorrect: Using parentheses () tries to "call" the list.
first_item = my_list(0)
Output:
Traceback (most recent call last):
File "main.py", line 4, in <module>
first_item = my_list(0)
TypeError: 'list' object is not callable
Solution: to access list elements, you must use square brackets [] with the integer index of the element you want to retrieve.
my_list = [10, 20, 30]
# ✅ Correct: Use square brackets [] for indexing.
first_item = my_list[0]
second_item = my_list[1]
print(f"The first item is: {first_item}")
print(f"The second item is: {second_item}")
Output:
The first item is: 10
The second item is: 20
Cause 2: Variable Name Shadowing the Built-in list() Function
This error can also occur if you accidentally name a variable list. This reassignment "shadows" or hides the built-in list() constructor function. When you later try to use the actual list() function to create a new list, you will instead be trying to "call" your list variable.
Example of code causing the error:
# ❌ Incorrect: The variable 'list' now holds a list object, overwriting the built-in function.
list = [1, 2, 3]
# This line now tries to "call" the list variable [1, 2, 3], not the function.
another_list = list((5, 6, 7))
Output:
Traceback (most recent call last):
File "main.py", line 5, in <module>
another_list = list((5, 6, 7))
TypeError: 'list' object is not callable
Solution: never use the names of built-in functions or types (like list, str, dict, sum) as variable names. Choose a descriptive name for your variable instead.
# ✅ Correct: Use a unique variable name.
my_first_list = [1, 2, 3]
# The built-in list() function is no longer shadowed and works as expected.
my_second_list = list((5, 6, 7))
print(my_first_list)
print(my_second_list)
Output:
[1, 2, 3]
[5, 6, 7]
Avoid Shadowing Built-ins:
It is a critical best practice in Python to avoid using names of built-in functions for your variables. Doing so can lead to confusing errors like this one. Other common examples to avoid are dict, str, int, set, sum, max, and min.
Conclusion
The TypeError: 'list' object is not callable is always caused by using the call operator () on a variable that contains a list. To fix it, you need to find where this is happening in your code:
| If the cause is... | The solution is... |
|---|---|
Incorrectly trying to access a list item (e.g., my_list(0)) | Use the correct square bracket [] syntax for indexing: my_list[0]. |
A variable name that is the same as the built-in list type (e.g., list = [1, 2]) | Rename your variable to something that is not a built-in name (e.g., my_list). |
By checking for these two common mistakes, you can easily diagnose and resolve this TypeError.