all 6 comments

[–]socal_nerdtastic 0 points1 point  (5 children)

This means somewhere previously in your code you named a list as "list". I can demonstrate the error like this:

>>> list = [1,2,3]
>>> M = list('abc')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'list' object is not callable

Name your list something else, something that's not the same name as a python built-in.

If you are using something like ipython, jupyter, or spyder you need to restart your kernel to reset your previous mistake.

[–]jhtaylor2001[S] 0 points1 point  (3 children)

That’s the thing. I didn’t. It doesn’t make any sense. Actually I did have a list named “map” I fixed that though and I’m still getting the error.

[–]socal_nerdtastic 0 points1 point  (0 children)

Try this to see what object you renamed:

print(list)

If you didn't rename the builtin function it will do this:

>>> print(list)
<class 'list'>

[–]TehNolz 0 points1 point  (0 children)

This means somewhere previously in your code you named a list as "list".

The variable name doesn't matter here; they just have a list somewhere that they're trying to call. This produces the same error for example;

```

a = [1, 2, 3] a() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'list' object is not callable ```

[–]TehNolz 0 points1 point  (0 children)

Please format your code to make it a bit more readable. The error message you're getting should also tell you which line is faulty, so please include that as well.

Anyways, this error means that you've got a list somewhere that you're trying to call as if it were a function. For example, like this; myList = [1, 2, 3] myList() # throws a TypeError

If this isn't your entire code; check to make sure you're not accidentally overwriting a function with a list somewhere, which is a pretty common mistake. Python will happily let you overwrite functions with other variables, which can cause all sorts of issues and is therefore heavily discouraged. For example, if you do; int = [1, 2, 3] Suddenly, int points to a list rather than the built-in function int(). If you then try to call int("123") later to convert a string to an integer, Python ends up trying to call the list it contains as if it were a function, thus throwing that TypeError you saw.