List[List[str]]报错问题

class Sun:
global List
List=[]

def numIslands(self, grid:** List[List[str]**]) -> int:
    sum = 0
    q = []
    m = len(grid)
    if m == 0:
        return 0
    n = len(grid[0])
    dx = [0,0,1,-1]
    dy = [1,-1,0,0]
    for r in range(m):
        for c in range(n):
            if grid[r][c] == '1':
                grid[r][c] == '0'
                q.append((r,c))
                while len(q):
                    Q = q.pop(0)
                    index_r = Q[0]
                    index_c = Q[1]
                    for i in range(4):
                        x = index_r + dx[i]
                        y = index_c + dy[i]
                        if x >= 0 and x < m and y >= 0 and y < n and grid[x][y] == '1':
                            grid[x][y] = '0'
                            q.append((x,y))
                sum += 1
    return sum

List[List[str]]在此处报错说List not define

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^