Python TypeError: ‘list’ object is not callable
In this Python tutorial, we will discuss how to fix “typeerror and attributeerror” in python. We will check:
- TypeError: ‘list’ object is not callable.
- TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’.
- Python object has no attribute
- TypeError: python int object is not subscriptable
Table of Contents
TypeError: ‘list’ object is not callable
In python, we get this error when we pass the argument inside the print statement, the code contains the round bracket to print each item in the list due to which we get this typeerror.
Example:
After writing the above code, Ones you will print “my_list(value)” then the error will appear as a “ TypeError: ‘list’ object is not callable ”. Here, this error occurs because we are using the round bracket which is not correct for printing the items.
You can see the below screenshot for this typeerror in python
To solve this python typeerror we have to pass the argument inside the square brackets while printing the “value” because the list variable works in this way.
Example:
After writing the above code, Ones you will print “ my_list[value] ” then the output will appear as a “ Kiyara Elon John Sujain ”. Here, the error is resolved by giving square brackets while printing.
You can refer to the below screenshot how typeerror is resolved.

TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’
We get unsupported operand type(s) for +: ‘int’ and ‘str’ error when we try to add an integer with string or vice versa as we cannot add a string to an integer.
Example:
After writing the above code, Ones you will print “(s)” then the error will appear as a “ TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’ ”. Here, this error occurs because we are trying to add integer and string so it returns an error.
You can see the below screenshot typeerror: unsupported operand type(s) for +: ‘int’ and ‘str’ in python

To solve this python typeerror we have to convert the string value to an integer using the int() method so, in this way we can avoid this error.
Example:
After writing the above code, Ones you will print “ (s) ” then the output will appear as a “ 15 ”. Here, the error is resolved by converting the value of a2 to an integer type, and then it added two values.
You can refer to the below screenshot of how unsupported operand type(s) for +: ‘int’ and ‘str’ is resolved.

Python object has no attribute
In python, we get this attribute error because of invalid attribute reference or assignment.
Example:
After writing the above code, Ones you will print “a” then the error will appear as an “ AttributeError: ‘int’ object has no attribute ‘append’ ”. Here, this error occurs because of invalid attribute reference is made and variable of integer type does not support append method.
You can see the below screenshot for attribute error

To solve this python attributeerror we have to give a variable of list type to support the append method in python, so it is important to give valid attributes to avoid this error.
Example:
After writing the above code, Ones you will print then the output will appear as an “Updated roll in list: [‘1’, ‘2’, ‘3’, ‘4’, ‘5’] ”. Here, the error is resolved by giving the valid attribute reference append on the list.
You can refer to the below screenshot how attributeerror is resolved.

TypeError: python int object is not subscriptable
This error occurs when we try to use integer type value as an array. We are treating an integer, which is a whole number, like a subscriptable object. Integers are not subscriptable object. An object like tuples, lists, etc is subscriptable in python.
Example:
- After writing the above code, Once you will print “ v_int[0] ” then the error will appear as a “ TypeError: ‘int’ object is not subscriptable ”.
- Here, this error occurs because the variable is treated as an array by the function, but the variable is an integer.
- You can see we have declared an integer variable “v_int” and in the next line, we are trying to print the value of integer variable “v_int[0]” as a list. Which gives the error.
You can see the below screenshot for typeerror: python int object is not subscriptable

To solve this type of error ‘int’ object is not subscriptable in python, we need to avoid using integer type values as an array. Also, make sure that you do not use slicing or indexing to access values in an integer.
Example:
After writing the above code, Once you will print “ v_int ” then the output will appear as “ 1 ”. Here, the error is resolved by removing the square bracket.
You can see the below screenshot for typeerror: python int object is not subscriptable

You may like the following Python tutorials:
This is how to fix python TypeError: ‘list’ object is not callable, TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’, AttributeError: object has no attribute and TypeError: python int object is not subscriptable

Python is one of the most popular languages in the United States of America. I have been working with Python for a long time and I have expertise in working with various libraries on Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… I have experience in working with various clients in countries like United States, Canada, United Kingdom, Australia, New Zealand, etc. Check out my profile.
Python TypeError: Object is Not Callable. Why This Error?
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!
Table of Contents
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.
Let’s test this function with few Python objects…
Lists are not callable
Tuples are not callable
Lambdas are callable
Functions are callable
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.
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.
Now, create an object of type Person:
Below you can see the only attribute of the object:
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.
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.
Let’s execute the program:
Interesting, something in the if condition is causing the error ‘float’ object is not callable.
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.
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.
No way, the object is not callable error again!

To understand why check the official Python documentation for sys.version.
We have added parentheses at the end of sys.version but this object is a string and a string is not callable.
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:
Now access the first element in this list:
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:
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.
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:
Conclusion
Now that we went through few scenarios in which the error object is not callable can occur you should be able to fix it quickly if it occurs in your programs.
How to fix "‘list’ object is not callable" in Python
✋ Update: This post was originally published on my blog decodingweb.dev, where you can read the latest version for a user experience.
The “TypeError: ‘list’ object is not callable” error occurs when you try to call a list ( list object) as if it was a function!
Here’s what the error looks like:
Exit fullscreen mode
Calling a list object as if it’s a callable isn’t what you’d do on purpose, though. It usually happens due to a wrong syntax or overriding a function name with a list object.
Let’s explore the common causes and their solutions.
How to fix TypeError: ‘list’ object is not callable?
This TypeError happens under various scenarios:
- Declaring a variable with a name that’s also the name of a function
- Indexing a list by parenthesis rather than square brackets
- Calling a method that’s also the name of a property
- Calling a method decorated with @property
Declaring a variable with a name that’s also the name of a function: A Python function is an object like any other built-in object, such as str , int , float , dict , list , etc.
All built-in functions are defined in the builtins module and assigned a global name for easier access. For instance, list refers to the __builtins__.list function.
That said, overriding a function (accidentally or on purpose) with any value (e.g., a list object) is technically possible.
In the following example, we’ve declared a variable named list containing a list of numbers. In its following line, we try to create another list — this time by using the list() and range() functions:
Exit fullscreen mode
If you run the above code, Python will complain with a «TypeError: ‘list’ object is not callable» error because we’ve already assigned the list name to the first list object.
We have two ways to fix the issue:
- Rename the variable list
- Explicitly access the list() function from the builtins module ( __bultins__.list )
The second approach isn’t recommended unless you’re developing a module. For instance, if you want to implement an open() function that wraps the built-in open() :
Exit fullscreen mode
In almost every other case, you should always avoid naming your variables as existing functions and methods. But if you’ve done so, renaming the variable would solve the issue.
So the above example could be fixed like this:
Exit fullscreen mode
This issue is common with function names you’re more likely to use as variable names. Functions such as vars , locals , list , all , or even user-defined functions.
In the following example, we declare a variable named all containing a list of items. At some point, we call all() to check if all the elements in the list (also named all ) are True :
Exit fullscreen mode
Obviously, we get the TypeError because the built-in function all() is now shadowed by the new value of the all variable.
To fix the issue, we choose a different name for our variable:
Exit fullscreen mode
⚠️ Long story short, you should never use a function name (built-in or user-defined) for your variables!
Overriding functions (and calling them later on) is the most common cause of the «TypeError: ‘list’ object is not callable» error. It’s similar to calling integer numbers as if they’re callables.
Now, let’s get to the less common mistakes that lead to this error.
Indexing a list by parenthesis rather than square brackets: Another common mistake is when you index a list by () instead of [] . Based on Python semantics, the interpreter will see any identifier followed by a () as a function call. And since the parenthesis follows a list object, it’s like you’re trying to call a list.
As a result, you’ll get the «TypeError: ‘list’ object is not callable» error.
Exit fullscreen mode
This is how you’re supposed to access a list item:
Exit fullscreen mode
Calling a method that’s also the name of a property: When you define a property in a class constructor, it’ll shadow any other attribute of the same name.
Exit fullscreen mode
In the above example, since we have a property named authors , the method authors() is shadowed. As a result, any reference to authors will return the property authors , returning a list object. And if you call this list object value like a function, you’ll get the «TypeError: ‘list’ object is not callable» error.
The name get_authors sounds like a safer and more readable alternative:
Exit fullscreen mode
Calling a method decorated with @property decorator: The @property decorator turns a method into a “getter” for a read-only attribute of the same name. You need to access a getter method without parenthesis, otherwise you’ll get a TypeError.
Exit fullscreen mode
To fix it, you need to access the getter method without the parentheses:
Exit fullscreen mode
Alright, I think it does it! I hope this quick guide helped you fix your problem.
Why does "example = list(. )" result in "TypeError: 'list' object is not callable"? [duplicate]
I tried to use this code from a tutorial at the REPL:
The tutorial says that example should become equal to a list [‘e’, ‘a’, ‘s’, ‘y’, ‘h’, ‘o’, ‘s’, ‘s’] . But I got an error instead:
Why did this happen?
14 Answers 14
Seems like you’ve shadowed the builtin name list , which points at a class, by the same name pointing at an instance of it. Here is an example:
I believe this is fairly obvious. Python stores object names (functions and classes are objects, too) in namespaces (which are implemented as dictionaries), hence you can rewrite pretty much any name in any scope. It won’t show up as an error of some sort. As you might know, Python emphasizes that "special cases aren’t special enough to break the rules". And there are two major rules behind the problem you’ve faced:
Namespaces. Python supports nested namespaces. Theoretically you can endlessly nest them. As I’ve already mentioned, they are basically dictionaries of names and references to corresponding objects. Any module you create gets its own "global" namespace, though in fact it’s just a local namespace with respect to that particular module.
Scoping. When you reference a name, the Python runtime looks it up in the local namespace (with respect to the reference) and, if such name does not exist, it repeats the attempt in a higher-level namespace. This process continues until there are no higher namespaces left. In that case you get a NameError . Builtin functions and classes reside in a special high-order namespace __builtins__ . If you declare a variable named list in your module’s global namespace, the interpreter will never search for that name in a higher-level namespace (that is __builtins__ ). Similarly, suppose you create a variable var inside a function in your module, and another variable var in the module. Then, if you reference var inside the function, you will never get the global var , because there is a var in the local namespace — the interpreter has no need to search it elsewhere.
Here is a simple illustration.
So, as you see there is nothing special about Python builtins. And your case is a mere example of universal rules. You’d better use an IDE (e.g. a free version of PyCharm, or Atom with Python plugins) that highlights name shadowing to avoid such errors.
You might as well be wondering what is a "callable", in which case you can read this post. list , being a class, is callable. Calling a class triggers instance construction and initialisation. An instance might as well be callable, but list instances are not. If you are even more puzzled by the distinction between classes and instances, then you might want to read the documentation (quite conveniently, the same page covers namespaces and scoping).
If you want to know more about builtins, please read the answer by Christian Dean.