Resolved TypeError: ‘list’ object is not callable’ in Python[SOLVED]

In this tutorial, learn how to resolve the error showing TypeError: ‘list’ object is not callable’ in Python. The short answer is: use the square bracket ([]) in place of the round bracket when the Python list is not callable.

This error shows that the object in Python programming is not callable. To make it callable, you have to understand carefully the examples given here. The first section of the example contains the callable error showing TypeError: ‘list’ object is not callable’. While the second section showing the solution for the error.

The output of the second section example contains no error in the output. So, let’s start writing the error output and the program without error. First, start with the error example showing the TypeError: ‘list’ object is not callable’.

Code with Error : TypeError: ‘list’ object is not callable’ in Python

Here, in this example, you have to use the for loop of Python to print each element of the list. Include the print statement after the for loop to print the items of the list in Python.

However, the code contains the round bracket when passing x as an argument inside the print statement. This round bracket is not the correct way to print each element of a list in Python.

Output

TypeError: ‘list’ object is not callable

The above example gives an error output with the error message that the Python list is not callable. Read the next section to find out how to resolve the error TypeError: ‘list’ object is not callable’ in Python.

Bonus: download a Free Python cheat sheet that will show you 20+ most important examples to learn in Python.

How to Resolve The Error in Python list is not callable

To resolve the problem of the error in the Python code. You have passed the variable x as the argument inside the square brackets.

But it should not appear as myList(0), myList(1) in the output. The above example showing the callable error with this round bracket as given in the above section.

Because the list variable works the same as the array element. To print each element of the list variable of Python, you have to print the list as myList[0], myList[1]...myList[n]. Below is the example of for loop which gives this type of result in the output without any error.

Output

Ram
Shyam
10
Bilal
13.2
Feroz

The output of the above example gives no error and print each element in a single line.

DOWNLOAD Free PYTHON CHEAT SHEET

You may also like to read

I hope you like this tutorial on how to resolve the error in Python.

References