Home › Python

TypeError: 'list' object is not callable (Python) — how to fix

Traceback (most recent call last):
  File "main.py", line 3, in <module>
    items = list(range(5))
TypeError: 'list' object is not callable

Quick fix: Rename any variable called list (e.g. list = [...] → items = [...]), then del list in an open REPL/notebook or restart the kernel. Use square brackets for indexing: my_list[0], not my_list(0).

What it means

Writing x(...) calls x. When x is a list object, Python can't call it and raises this error. The traceback line shows which expression had the parentheses.

Cause 1: you named a variable list

The most common cause. Assigning to list hides the built-in type for the rest of the scope:

list = [1, 2, 3]          # shadows built-in list
...
numbers = list(range(5))  # TypeError: 'list' object is not callable

Fix: rename the variable.

values = [1, 2, 3]
numbers = list(range(5))

In Jupyter or the REPL the bad assignment survives even after you edit the cell. Remove it or restart the kernel:

del list

Same trap with dict, str, set, tuple, sum, max, input, type. Linters catch it: pylint redefined-builtin, ruff A001.

Cause 2: parentheses instead of square brackets

names = ["ana", "bo"]
print(names(0))     # wrong
print(names[0])     # right

Also for slices: names[1:3], not names(1:3).

Cause 3: an attribute or method was overwritten by a list

class Cart:
    def __init__(self):
        self.items = []
    def items(self):          # this method is hidden by self.items
        return self.items

Cart().items()                # TypeError

Give the attribute and the method different names (self._items and def items(self)), or use a @property.

Cause 4: a function returns a list and you call the result

def get_handlers():
    return [a, b]

get_handlers()()      # calling the returned list

Index first, then call: get_handlers()[0](), or loop:

for handler in get_handlers():
    handler()

Cause 5: a parameter named list

def process(list):
    return list(set(list))    # 'list' here is the argument

Rename the parameter to items.

How to find it fast

grep -nE "^\s*list\s*=|def .*\(.*\blist\b" *.py

Or print the type right before the failing line: print(type(list)) — if it shows <class 'list'> instead of <class 'type'>, it's shadowed.

Last updated 2026-11-13.