'Unsupported target for indexed assignment
Function runs perfectly, but I am getting error with mypy:
Unsupported target for indexed assignment
Here is my code:
def function(image: List[str], start: Tuple[int]):
if image[start[0]][start[1]] == "*":
return
else:
image[start[0]][start[1]] = "*"
if start[0] > 0:
function(image, [start[0]-1, start[1]])
if start[0] < len(image) - 1:
function(image, [start[0]+1, start[1]])
if start[1] > 0:
function(image, [start[0], start[1]-1])
if start[1] < len(image) - 1:
function(image, [start[0], start[1]+1])
The mistake is in line:
image[start[0]][start[1]] = "*"
image = ["*", "."] start = (1, 1) - tuple contains coordinates.
Solution 1:[1]
self._balances:Mapping[str,Optional[float]]
If anyone comes here because of using Mapping, use MutableMapping instead, because you can only assign values to a mutable object
self._balances:MutableMapping[str,Optional[float]]
Solution 2:[2]
Problem solved.
The correct types are:
image: List[List[str]], start: Tuple[int, int]
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 | Peter |
| Solution 2 |
