TypeError: 'int' Object Is Not Subscriptable — What It Means and How to Fix It

If you've encountered the error "TypeError: 'int' object is not subscriptable," you're working with Python code that's trying to treat an integer as if it were a container (like a list, dictionary, or string). This is one of the most common type errors beginners encounter, and understanding why it happens is the key to fixing it—and preventing it in the future.

What Does "Not Subscriptable" Actually Mean? 🔍

Subscripting is programmer language for accessing elements inside a container using brackets. When you write my_list[0] or my_dict['key'], you're using subscript notation to retrieve a value. The error message tells you that Python tried to subscript something that doesn't support subscripting—in this case, an integer.

Integers are atomic values. They don't contain sub-elements. You can't ask "what's the third item inside the number 42?" That question doesn't make sense, and Python correctly rejects it.

When Does This Error Occur?

This error typically shows up in a few recognizable patterns: