Trying to retrieve data from an object and seeing an “object is not subscriptable” error instead? The problem is, you’re indexing the wrong data type.
Find out all about subscriptable types and how to resolve this error.

What Does “Subscriptable” Mean in Python?
The term “subscriptable” in Python means a data type that stores multiple values that you can access individually. You can access a specific value from a subscriptable data type via its index, using square bracket ([]) notation.
If you attempt to access the items in a data type that isn’t indexable, Python raises a “TypeError: object is not subscriptable” exception.
The following data types are subscriptable in Python: lists, strings, tuples, and dictionaries.
However, sets, integers, floats, and Booleans, are inaccessible via indexing, so they’re not subscriptable:
Attempting to run each of these statements outputs the “object is not subscriptable” exception:
Resolving the Exception
Resolving the “object is not subscriptable” exception is easier once you understand the rules for accessing each data type. So start your Python debugging by checking the data type of the object you’re trying to index.
Once you determine that the data type isn’t subscriptable, converting it to an indexable type resolves the problem. This is handy if the data is froma third-party API. Converting data types like integer, float, and Boolean into a string makes them subscriptable:
You can evenmanipulate the resulting Python stringsas you want. If dealing with integer and float, you might want to retain the original data type in the output. To do this, convert the resulting value into their original data type after indexing them as strings:
As for a set, you can transform it into a list. Although you can convert a set object into a list using thelist(set)Python one-liner, this doesn’t preserve the item positions in the resulting list. To ensure you get a list with preserved item positions, use Python’s lambda function like so:
Master Python Debugging
Python has a smooth learning curve. But simple exceptions can throw you off if you don’t know how to tackle them. Learning to debug your code and taking your time with problem-solving goes a long way to fixing Python coding errors and exceptions.