TypeError 'NoneType' object is not subscriptable
This error is quite self-descriptive:
1
2
3
4
5
6
7
8
9
Traceback (most recent call last):
File "users.py", line 25, in <module>
user = users[0]
TypeError: 'NoneType' object is not subscriptable
It means that you are trying to subscript (index) the object that actually is None. In the above example, the users
list is empty so you can’t get the first user from it since None object doesn’t define the __getitem__
method. This simply can be fixed by finding out Why the list is None
.