Home › Python

TypeError: 'builtin_function_or_method' object is not subscriptable (Python) — how to fix

TypeError: 'builtin_function_or_method' object is not subscriptable

Quick fix: Call the method with parentheses: my_list.append(x) not my_list.append[x], text.split()[0] not text.split[0]. If you shadowed nothing and meant to index a result, call first, then index: list(d.keys())[0].

What it means

"Subscriptable" means the object supports obj[...]. Functions and methods don't. builtin_function_or_method is the type of functions written in C, which includes the methods of list, dict, str and functions like len, max or input. Python is telling you that you wrote something[...] where something is one of those functions.

nums = [1, 2, 3]
nums.append[4]
# TypeError: 'builtin_function_or_method' object is not subscriptable

The fix is almost always to use parentheses.

Cause 1: brackets instead of parentheses on a method call

nums.append[4]        # wrong
nums.append(4)        # right

name = "a b c"
first = name.split[0]     # wrong
first = name.split()[0]   # right: call split(), then index its result

Cause 2: forgetting to call before indexing

You meant to index the result of the call, but left out ():

d = {"a": 1, "b": 2}
d.keys[0]            # error
list(d.keys())[0]    # 'a'

line = input[0]      # error
line = input()[0]    # first character of what the user typed

d.keys()[0] gives a different error ('dict_keys' object is not subscriptable) because a view isn't indexable; wrap it in list().

Cause 3: a method name used like an attribute

Some libraries expose values as methods, others as attributes. Mixing them up produces this error:

import numpy as np
a = np.array([[1, 2], [3, 4]])
a.shape[0]      # fine: shape is an attribute (a tuple)

import pandas as pd
df = pd.DataFrame({"x": [1, 2]})
df.head[0]      # error: head is a method -> df.head()

If you are not sure, check with type(obj.name) or callable(obj.name).

Cause 4: a variable shadowed by a built-in name

If you meant to index your own variable but its name matches a built-in that was never assigned (e.g. a typo like lst vs list, or the assignment is in another scope), you end up subscripting the built-in function:

def total():
    return sum[0]     # 'sum' here is the built-in, not your list

Rename your variables so they don't clash with built-ins (list, dict, sum, max, input, id), and make sure the variable is defined in the scope where you use it.

Quick check

Look at the expression right before [ on the line in the traceback and ask: is this a function? If yes, add () and index the return value instead.

Last updated 2026-12-02.