This error means you tried to use square brackets on something that doesn't support them
When Python throws "TypeError: 'builtin_function_or_method' object is not subscriptable," it means your code tried to access something using square brackets — like thing[0] — but the thing you're trying to access is a built-in function or method, not a container. Built-in functions and methods (like len, print, or str.upper) don't hold indexed data, so you can't use brackets on them.
The error almost always comes from one of two mistakes: either you forgot to call a function (you wrote the function name without parentheses), or you're trying to index into the result of a function call when that result isn't indexable. The fix depends on which one you did.
Key Takeaways
- The error occurs when you use square brackets on a function or method instead of on a data structure like a list, string, or dictionary.
- Forgetting parentheses — writing len instead of len(my_list) — is the most common cause.
- Some built-in functions return values that aren't indexable, so even calling them correctly can trigger this error if you then try to use brackets on the result.
- Check whether you meant to call a function (add parentheses), index into a container (make sure it's a list, string, or dict), or store the function result in a variable before indexing it.
The most common cause: forgetting to call the function
If you write len[my_list] instead of len(my_list), Python sees len as the built-in function object itself, not as a call to that function. When you then try to use brackets, Python complains that you can't subscript a function.
The fix is simple: use parentheses to call the function. len(my_list) calls the function and returns a number. len[my_list] tries to index into the function object, which fails. The same applies to any built-in: str(x) works, str[x] does not. print(message) works, print[message] does not.
When you're indexing the wrong thing
Sometimes you call a function correctly, but then try to index into its result when the result isn't a list, string, or dictionary. For example, dict.keys() returns a dict_keys object in Python 3, which you can't index directly with a number.
If you write my_dict.keys()[0], you'll get this error because dict.keys() returns a view object, not a list. To fix it, convert the result to a list first: list(my_dict.keys())[0]. The same applies to dict.values() and dict.items() — they return view objects, not lists.
Another common case: enumerate() returns an enumerate object, not a list. If you write enumerate(my_list)[0], it will fail. Convert it first: list(enumerate(my_list))[0].
Confusing a method with a property
If a class has a method (something you call with parentheses) and you forget the parentheses, you'll reference the method object itself rather than calling it. Then if you try to index into it, you get this error.
For example, if my_object.get_data is a method, writing my_object.get_data[0] tries to index the method object. You need my_object.get_data()[0] — call the method first, then index the result. Check your class definition to see whether something is a method (defined with def) or a property (defined with @property). Methods need parentheses; properties don't.
How to debug this error step by step
When you see this error, Python will tell you which line caused it. Look at that line and find the square brackets. Then ask: what comes before the brackets? Is it a function name, a method name, or a variable holding data?
If it's a function or method name (like len, print, str.upper, or my_object.some_method), you need parentheses to call it first. If it's a variable, check what that variable holds. If it holds a function object instead of data, you forgot to call the function somewhere earlier in your code. If it holds data that isn't indexable (like a dict_keys object or an enumerate object), convert it to a list before indexing.
Print the type of the thing you're trying to index: print(type(thing)). If it says <class 'builtin_function_or_method'> or <class 'method'>, you're trying to index a function. If it says something else, the issue is that the data type doesn't support indexing — convert it to a list or iterate over it differently.
Indexable vs. non-indexable types
You can use square brackets on strings, lists, tuples, and dictionaries. You cannot use them on functions, methods, sets, or generator objects. If you have a set and need to access an element by position, convert it to a list first: list(my_set)[0]. If you have a generator and need to index it, consume it into a list: my_list = list(my_generator), then index my_list.
When a built-in function returns something that isn't indexable, the documentation will tell you what type it returns. dict.keys() returns a dict_keys view, enumerate()` returns an enumerate object, zip() returns a zip object. None of these are indexable. If you need to index the result, wrap it in list() first.
Frequently Asked Questions
Why does Python say the object is not subscriptable when I'm trying to use brackets?
Subscriptable means it supports square bracket indexing. Functions and methods don't hold indexed data, so they're not subscriptable. You can only use brackets on data structures like lists, strings, and dictionaries, or on objects that define the __getitem__ method.
I called my function with parentheses but still get the error. What's wrong?
The function is being called correctly, but its return value isn't indexable. Check what type the function returns. If it's a view object (like dict_keys), a generator, or a set, convert it to a list before indexing: list(function_result)[0].
Can I index into a method the same way I index into a list?
No. Methods are functions attached to objects. You must call them first with parentheses to get their return value, then index that result if it's indexable. my_object.method()[0] works; my_object.method[0] does not.
What's the difference between a function and a method?
A function is defined at the module level and called by name: len(x). A method is defined inside a class and called on an object: my_list.append(x). Both are called with parentheses. Neither can be indexed directly.
How do I know if something is indexable?
Try indexing it and see if it works. If you want to check before trying, use hasattr(thing, '__getitem__') — if it returns True, the object supports indexing. Or print the type and check the documentation for that type.