TypeError: 'method' object is not subscriptable (tested fix)
TypeError: 'method' object is not subscriptable (or 'builtin_function_or_method', or is not iterable) means you used a method without calling it, as in obj.items[0] instead of obj.items()[0]. We reproduced every variant in Python 3.13.
1. A method used without ()
cart.items is the method itself; cart.items() is what it returns. Indexing the method raises the error:
class Cart:
def __init__(self):
self._items = ["apple", "pear"]
def items(self):
return self._items
cart = Cart()
try:
print(cart.items[0]) # forgot the ()
except TypeError as e:
print(type(e).__name__ + ":", e)
print(cart.items()[0])
Output:
TypeError: 'method' object is not subscriptable
apple
2. builtin_function_or_method: the same mistake on dict, str or a builtin
Methods of built-in types and builtins like len are written in C, so the message says builtin_function_or_method instead of method:
d = {"a": 1, "b": 2}
s = "hello"
for code in ["d.keys[0]", "d.get['a']", "s.split[0]", "len['abc']", "print['x']"]:
try:
eval(code)
except TypeError as e:
print(f"{code:12}", type(e).__name__ + ":", e)
print(list(d.keys())[0], d.get("a"), s.split()[0])
Output:
d.keys[0] TypeError: 'builtin_function_or_method' object is not subscriptable
d.get['a'] TypeError: 'builtin_function_or_method' object is not subscriptable
s.split[0] TypeError: 'builtin_function_or_method' object is not subscriptable
len['abc'] TypeError: 'builtin_function_or_method' object is not subscriptable
print['x'] TypeError: 'builtin_function_or_method' object is not subscriptable
a 1 hello
d.keys[0] needs two fixes: call it, and wrap it in list(), because dict_keys can't be indexed either.
3. The "is not iterable" variant in loops
d = {"a": 1, "b": 2}
for code in ["for k, v in d.items: pass", "for w in 'a b'.split: pass", "for x in len: pass", "sorted(d.values)"]:
try:
exec(code)
except TypeError as e:
print(f"{code:28}", type(e).__name__ + ":", e)
Output:
for k, v in d.items: pass TypeError: 'builtin_function_or_method' object is not iterable
for w in 'a b'.split: pass TypeError: 'builtin_function_or_method' object is not iterable
for x in len: pass TypeError: 'builtin_function_or_method' object is not iterable
sorted(d.values) TypeError: 'builtin_function_or_method' object is not iterable
class Cart:
def __init__(self):
self._items = ["apple", "pear"]
def items(self):
return self._items
@property
def names(self):
return self._items
cart = Cart()
try:
for item in cart.items: # forgot the ()
pass
except TypeError as e:
print(type(e).__name__ + ":", e)
print(cart.names[0], [n for n in cart.names])
Output:
TypeError: 'method' object is not iterable
apple ['apple', 'pear']
Looping over d.items without () is the classic one. If you want attribute-style access without parentheses on your own class, make it a @property.
4. A plain function: 'function' object is not subscriptable
def load():
return {"rows": [1, 2]}
for code in ["load['rows']", "load()['rows']"]:
try:
print(code, "->", eval(code))
except TypeError as e:
print(code, "->", type(e).__name__ + ":", e)
Output:
load['rows'] -> TypeError: 'function' object is not subscriptable
load()['rows'] -> [1, 2]
Three type names, one cause: function (your def), method (your class's method on an instance), builtin_function_or_method (C code). Add the (). The pandas variant (df.head[0], df.sum[...]) is the same mistake; we didn't run pandas for this page. Related: 'dict_keys' object is not subscriptable, object is not subscriptable and object is not iterable.
Frequently asked questions
How do I fix 'method' object is not subscriptable?
Add the parentheses: obj.items()[0], not obj.items[0].
What is builtin_function_or_method?
A function or method written in C, such as len, dict.keys or str.split. The error means you used one without calling it.
How do I fix 'builtin_function_or_method' object is not iterable?
You looped over a method like d.items without (). Write for k, v in d.items():.
Written with AI assistance. Measured on 2026-10-22 on Debian with Python 3.13.5: indexing and iterating your own methods, dict/str methods and builtins without (), a plain function, and a @property alternative. Every block was run verbatim and its output pasted unedited. pandas was not tested. PlainHeaders is our extension; Python is free.