'What does this error mean: "TypeError: Parameters to generic types must be types"?
I'm not sure what this error means:
TypeError: Parameters to generic types must be types. Got slice(typing.List, <class 'int'>, None).
I am trying to confirm if a matrix has a given cell/index in it.
(In matrix [[A, B, C], [D, E, F]] does cell/index [0, 2] exist? Yes at C).
My input parameter is a list specifying the cell's index. I want to take the cell/list and modify it to check if it exists. Every time I try to touch the parameter list, it gives the error.
def in_matrix(matr: List[List:int], cell: List[int]) -> bool:
b = cell.pop()
a = cell.pop()
print(a)
print(b)
for y in range(len(matr)):
for x in range(len(matr[y])):
if matr[a][b] == True:
return True
else:
return False
Solution 1:[1]
This type matr: List[List:int] should be matr: List[List[int]] (in Python >= 3.9 you can even just use matr: list[list[int]]).
This means that matr is a list of integer lists, like:
matr = [[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
