Last modified: Dec 04, 2025 By Alexander Williams
Fix TypeError: 'method' object is not subscriptable
Python errors can be confusing for beginners. The "TypeError: 'method' object is not subscriptable" is a common one. It often stops your code from running. This article explains what it means. We will show you how to fix it step by step.
What Does This Error Mean?
Python raises this error when you try to use square brackets on a method. Square brackets are for indexing or slicing. They work on sequences like lists, tuples, and strings. A method is a function attached to an object. You cannot use [] on a method directly.
The error message is clear. It tells you the object type is a 'method'. It says this type does not support subscripting. Subscripting is the technical term for using [].
Common Cause: Forgetting Parentheses
The most frequent cause is simple. You forget to call the method. You write the method name without parentheses. Python sees the method object itself. Then you try to index it. This causes the error.
Let's look at a classic example with a list.
# Incorrect code causing the error
my_list = [1, 2, 3, 4, 5]
# Trying to get the last item incorrectly
last_item = my_list.pop[0] # Forgot parentheses!
print(last_item)
Traceback (most recent call last):
File "script.py", line 4, in
last_item = my_list.pop[0]
TypeError: 'builtin_function_or_method' object is not subscriptable
See the problem? We used my_list.pop[0]. The pop is a method. We need to call it with parentheses: my_list.pop(0). The corrected code works perfectly.
# Corrected code
my_list = [1, 2, 3, 4, 5]
last_item = my_list.pop(0) # Called with parentheses
print(last_item)
1
Another Example: String Methods
This error is not just for lists. It happens with all object methods. String methods are a common victim. Let's see an example with split.
# Trying to index the split method incorrectly
text = "hello world python"
first_word = text.split[0] # Error: split is a method object here
print(first_word)
Again, we forgot the parentheses. The split method returns a list. We can then index that list. The fix is to call the method first.
# Correct way: call the method, then index
text = "hello world python"
words = text.split() # This returns a list: ['hello', 'world', 'python']
first_word = words[0]
print(first_word)
hello
Debugging the Error Step-by-Step
Follow these steps when you see this error.
1. Find the line. The traceback points to the exact line. Look at the variable or object before the [].
2. Identify the object. Is it supposed to be a list, dict, or string? Or is it a method name?
3. Check for parentheses. If it's a method, did you call it? Add () if missing.
4. Print the type. Use print(type(your_variable)) to see what it is.
Related Errors and Confusion
This error is part of a family. The core issue is trying to use an operation on the wrong data type. For instance, a similar error is 'set' object is not subscriptable. Sets are another unindexable collection.
Another common mix-up is with the 'builtin_function_or_method' not subscriptable error. It's essentially the same problem. It happens with built-in functions like len or print.
Beginners also often face the TypeError: 'NoneType' is not iterable. This happens when a function returns None and you try to loop over it. Always check your function return values.
Advanced Scenario: Method Aliasing
Sometimes you assign a method to a variable. This can lead to the error in a less obvious way. Look at this code.
my_dict = {'a': 1, 'b': 2}
# Assigning the .keys() method to a variable (without calling it)
key_method = my_dict.keys # No parentheses!
# Later, trying to treat this variable as a list
first_key = key_method[0] # This will fail
Here, key_method holds the method object. The fix is to call the method when assigning or before indexing.
my_dict = {'a': 1, 'b': 2}
# Correct: Call the method to get the view object
keys_list = list(my_dict.keys()) # Convert to a list
first_key = keys_list[0]
print(first_key)
a
Conclusion
The "TypeError: 'method' object is not subscriptable" is a beginner-friendly error. It tells you exactly what's wrong. You tried to index something that isn't indexable. The solution is almost always to add parentheses to call the method.
Remember the pattern. Methods need () to execute. Their return value can often be indexed. Keep this in mind, and you'll fix this error quickly. For more on type errors, see our guides on fixing 'int' and 'str' Python errors and handling 'tuple' object does not support item assignment.
Happy coding!