Do you encounter this stupid error?
TypeError: 'builtin_function_or_method' object is not subscriptable
You’re not alone—thousands of coders like you experience this error in thousands of projects every month. This short tutorial will show you exactly why this error occurs, how to fix it, and how to never make the same mistake again. So, let’s get started!
Three examples when this might occur:
>>> [1,2,3].append Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> [1,2,3].append TypeError: 'builtin_function_or_method' object is not subscriptable
>>> [1,2,3].extend[1,2,3] Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> [1,2,3].extend[1,2,3] TypeError: 'builtin_function_or_method' object is not subscriptable
>>> print Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> print TypeError: 'builtin_function_or_method' object is not subscriptable
Quick Solution 👇
Python raises the
TypeError 'builtin_function_or_method' is not subscriptable if you use the square bracket notation on a non-sequence type.
Fix it by using parentheses
f() instead of square brackets
f when calling a built-in method or function.
Example Fixes 🎯
For example, use
You get the point—replace the square bracket notation
 with the parentheses notation
When Does Error Occur? 🔍
💡 In general, the
TypeError 'builtin_function_or_method' is not subscriptable occurs if you use the square bracket notation on any built-in function or method on a built-in data type such as lists.
Here’s a collection of all built-in list methods where this or a similar error will occur when using the square bracket notation:
|Appends element |
|Removes all elements from the list |
|Returns a copy of the list |
|Counts the number of occurrences of element |
|Adds all elements of an iterable |
|Returns the position (index) of the first occurrence of value |
|Inserts element |
|Removes and returns the final element of the list |
|Removes and returns the first occurrence of element |
|Reverses the order of elements in the list |
|Sorts the elements in the list |
👉 Recommended Tutorial: Python List Methods
Here’s a collection of all built-in functions where this or a similar error will occur when using the square bracket notation:
👉 Recommended Tutorial: Python Built-in Functions
I hope you’d be able to fix the bug in your code! Before you go, check out our free Python cheat sheets that’ll teach you the basics in Python in minimal time:
Related TypeError Messages
🌍 This was a very generic tutorial. You may have encountered a similar but slightly different variant of this error message. Have a look at the following tutorials to find out more about those!
- [Fixed] Matplotlib: TypeError: ‘AxesSubplot’ object is not subscriptable
- [Fixed] TypeError: ‘int’ object is not subscriptable
- [Fixed] Python TypeError: ‘float’ object is not subscriptable
- [Fixed] Python TypeError ‘set’ object is not subscriptable
- [Fixed] Python TypeError ‘bool’ object is not subscriptable
- (Solved) Python TypeError ‘Method’ Object is Not Subscriptable
Programming Humor – Python
While working as a researcher in distributed systems, Dr. Christian Mayer found his love for teaching computer science students.
To help students reach higher levels of Python success, he founded the programming education website Finxter.com that has taught exponential skills to millions of coders worldwide. He’s the author of the best-selling programming books Python One-Liners (NoStarch 2020), The Art of Clean Code (NoStarch 2022), and The Book of Dash (NoStarch 2022). Chris also coauthored the Coffee Break Python series of self-published books. He’s a computer science enthusiast, freelancer, and owner of one of the top 10 largest Python blogs worldwide.
His passions are writing, reading, and coding. But his greatest passion is to serve aspiring coders through Finxter and help them to boost their skills. You can join his free email academy here.