This error means you tried to use square brackets on something that doesn't support them

The error "TypeError: 'builtin_function_or_method' object is not subscriptable" appears when your Python code tries to access an item using square brackets [] on a built-in function or method. Built-in functions like len(), print(), or type() are not containers — they don't hold items you can retrieve by index or key. When Python sees you trying to use brackets on one of them, it stops and throws this error.

The word "subscriptable" means "able to be accessed with square brackets." Lists, dictionaries, strings, and tuples are subscriptable. Functions and methods are not. This is one of the most common mistakes when you're learning Python, and it almost always comes from either forgetting to call a function, or accidentally putting brackets where you meant to put parentheses.

Key Takeaways

  • This error occurs when you use square brackets [] on a function or method instead of parentheses ().
  • The most common cause is writing len[x] instead of len(x), or print[x] instead of print(x).
  • Another cause is forgetting to call a function before trying to access its result — for example, storing the function itself instead of what it returns.
  • You can fix this by replacing square brackets with parentheses when calling functions, or by actually calling the function if you stored it without parentheses.

The most common cause: brackets instead of parentheses

The single most frequent reason for this error is typing square brackets when you meant to type parentheses. Python uses parentheses () to call functions and pass arguments. Square brackets [] are for accessing items inside a container.

Here is the mistake:

result = len[my_list]

Here is the fix:

result = len(my_list)

The same applies to any built-in function: type(), print(), str(), int(), list(), dict(), sorted(), reversed(), enumerate(), zip(), and others. If you see this error, search your code for any line where you're using square brackets on a function name, and change them to parentheses.

Storing a function without calling it

The second common cause is storing a function object itself instead of the result of calling that function. When you write a function name without parentheses, Python treats it as the function object, not as a call to run that function.

Here is the mistake:

my_function = len result = my_function[5]

The variable my_function now holds the function object itself, not a result. When you try to use square brackets on it, Python throws the error. Here is the fix:

my_function = len result = my_function(5)

Or, if you meant to store the result of calling the function on a specific input:

my_list = [1, 2, 3] my_function = len(my_list) result = my_function

Now my_function holds the number 3, not the function itself.

Methods on objects work the same way

Methods are functions attached to objects. They also use parentheses, not square brackets. If you have a string and want to call its upper() method, you use parentheses:

text = "hello" result = text.upper()

Not:

result = text.upper[0]

If you want to access a character in the result, call the method first, then use brackets on the result:

result = text.upper()[0]

This calls upper(), which returns "HELLO", then uses brackets to get the first character, "H".

How to find and fix the error in your code

When you see this error, Python will tell you which line caused it. Look at that line and search for square brackets. Ask yourself: am I using brackets on a function name, or on something that should be a function call?

The error message will include a line number and the name of the function or method involved. For example:

TypeError: 'builtin_function_or_method' object is not subscriptable File "script.py", line 5, in <module>

Go to line 5 of your script. Look for any use of square brackets on a function. Replace them with parentheses. If the line looks correct, check the lines above it to see if you stored a function without calling it.

A quick way to test: if you're not sure whether something is a function or a value, print its type. If it says <class 'builtin_function_or_method'>, you're holding the function itself, not its result. Call it with parentheses to get the actual value.

Frequently Asked Questions

Why does Python use parentheses for functions and brackets for lists?

Parentheses signal "run this code" — they tell Python to execute the function and return a result. Square brackets signal "get an item from this container" — they tell Python to look inside something that already exists. The two operations are different, so Python uses different symbols to keep them clear.

Can I use brackets on any kind of function?

No. Only objects that are subscriptable — like lists, dictionaries, strings, and tuples — support square brackets. Functions, methods, and most other objects do not. If you try, you get this error.

What if I want to call a function and then access an item in the result?

Use parentheses to call the function, then square brackets on the result. For example: len(my_list)[0] would fail because len() returns a number, which is not subscriptable. But sorted(my_list)[0] works because sorted() returns a list, which is subscriptable.

Does this error happen with custom functions I write myself?

Yes. If you write your own function and someone (or you) tries to use square brackets on it, you get the same error. The rule is the same: use parentheses to call any function, whether it's built-in or custom.