Here is a solve function which solves a sudoku puzzle:
def solve(grid):
for y in range(9):
for x in range(9):
if grid[y][x]==0:
for n in range(1,10):
if possible(grid,y,x,n):
grid[y][x]=n
solve(grid)
grid[y][x]=0
return
print(np.matrix(grid))
return grid
When solve function is called, it takes a matrix 9*9 sudoku puzzle and prints the solved puzzle.
The function works properly and the puzzle gets printed the right way. But instead of printing the puzzle I want the function to return the grid matrix and return in a variable like this:
solved_grid=solve(grid)
Instead of returning the grid the solve function returns None.
Kindly advise. Thanks in advance