# Почему у меня не повторяется ошибка объекта int? [closed]

Я тренирую свои навыки программирования и пытаюсь решить Путь с максимальной проблемой золота от LeetCode. Мой текущий код ниже

``````from typing import List

class Solution:
def getMaximumGold(self, grid: List[List[int]]) -> int:
total_gold = 0
m = len(grid)
n = len(grid[0])
for i in range(m):
for j in range(n):
if grid[i][j] != 0:
visited = []
path_from_cell = self.searchForPath(m, n, i, j, grid, visited)
total_gold = max(total_gold, path_from_cell)

def searchForPath(self, m, n, i, j: int, grid: List[List[int]], visited) -> int:
if grid[i][j] == 0 or [i,j] in visited or i<0 or j<0 or i>=m or j>=n:
return 0
else:
visited.append([i,j])
left = self.searchForPath(m, n, i, j-1, grid, visited)
right = self.searchForPath(m, n, i, j+1, grid, visited)
up = self.searchForPath(m, n, i-1, j, grid, visited)
down = self.searchForPath(m, n, i+1, j, grid, visited)
visited.remove([i,j])
return max(left,max(right,max(up,max(down)))) + grid[i][j]

print(Solution().getMaximumGold(grid = [[0,6,0],[5,8,7],[0,9,0]]))
``````

Выдает следующую ошибку:

``````Traceback (most recent call last):
File "/home/hasek/Documents/Programming/leetcode.py", line 28, in <module>
print(Solution().getMaximumGold(grid = [[0,6,0],[5,8,7],[0,9,0]]))
File "/home/hasek/Documents/Programming/leetcode.py", line 12, in getMaximumGold
path_from_cell = self.searchForPath(m, n, i, j, grid, visited)
File "/home/hasek/Documents/Programming/leetcode.py", line 24, in searchForPath
down = self.searchForPath(m, n, i+1, j, grid, visited)
File "/home/hasek/Documents/Programming/leetcode.py", line 21, in searchForPath
left = self.searchForPath(m, n, i, j-1, grid, visited)
File "/home/hasek/Documents/Programming/leetcode.py", line 26, in searchForPath
return max(left,max(right,max(up,max(down)))) + grid[i][j]
TypeError: 'int' object is not iterable
``````

Я не вижу, что случилось. Любая помощь будет оценена по достоинству.