Python - TypeError – NoneType Object not Subscriptable

The error is self-explanatory. You are trying to subscript an object which you think is a list or dict, but actually is None. This means that you tried to do:


This error means that you attempted to index an object that doesn’t have that functionality. You might have noticed that the method sort() that only modify the list have no return value printed – they return the default None. ‘NoneType’ object is not subscriptable is the one thrown by python when you use the square bracket notation object[key] where an object doesn’t define the getitem method . This is a design principle for all mutable data structures in Python.

Python has two ways of representing missing data that are NaN and Na. The NaN means “Not a Number”, and it means there is a result, but it cannot be represented in the computer. The second is NA means Not Available, which means that the data is missing for unknown reasons. Let’s deep dive into NA in Python.