I\'m really unsure why this isn\'t working. Here is the important part of the code (it\'s from a leetcode challenge). The first line throws the NameError.
To be able to annotate what types your list should accept, you need to use typing.List
typing.List
from typing import List
So did you import List?
List
Update
If you're using Python 3.9, see @Adam.Er8's answer