TypeError: 'NoneType' object is 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:
None[something]
NoneType is the type of the None object which represents a lack of value, for example, a function that does not explicitly return a value will return None .
example
list1 = [1, 2]
list1 = list.sort(list1)
temp = list1[0]
you will get the error message :
Traceback (most recent call last):
File "sample.py", line 3, in <module>
temp = list1[0]
TypeError: 'NoneType' object is not subscriptable
list1 = list.sort(list1) : - here, you are setting it to None. None always has no data and can not be subscriptable.
In order to correct this error this should be
list1 = [1, 2]
list1.sort()
temp = list1[0]
print(temp)

>>> None[0]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not subscriptable
>>>
Python typeerror
The Typeerror may be raised by user code to indicate that an attempted operation on an object is not supported, and is not meant to be. Passing arguments of the wrong type (e.g. passing a list when an int is expected) should result in a TypeError , but passing arguments with the wrong value (e.g. a number outside expected boundaries) should result in a ValueError . So you would get a TypeError if you tried list1 = list.sort(list1) because here you are setting it to None . None always has no data and can not be subscriptable.
Object is not subscriptable
A subscriptable object is any object that implements the __getitem__ special method (think lists, dictionaries). It is an object that records the operations done to it and it can store them as a "script" which can be replayed.
Related Topics
- IndexError: string index out of range
- IndentationError: unexpected indent Error
- ValueError: too many values to unpack (expected 2)
- SyntaxError- EOL while scanning string literal
- TypeError: Can't convert 'int' object to str implicitly
- IndentationError: expected an indented block
- ValueError: invalid literal for int() with base 10
- IndexError: list index out of range : Python
- AttributeError: 'module' object has no attribute 'main'
- UnboundLocalError: local variable referenced before assignment
- TypeError: string indices must be integers
- FileNotFoundError: [Errno 2] No such file or directory
- Fatal error: Python.h: No such file or directory
- ZeroDivisionError: division by zero
- ImportError: No module named requests | Python
- TypeError: 'NoneType' object is not iterable
- SyntaxError: unexpected EOF while parsing | Python
- zsh: command not found: python
- Unicodeescape codec can't decode bytes in position 2-3