title: Trouble understanding this sudoku solver recursion function (python)
body: <p>So basically I decided to make a sudoku solver in python and recursive functions is most efficient, but I've been trying to understand this code from a youtuber and don't understand why each space (bo[row][col]) doesn't immediately reset to 0.  The resetting of one space to 0 only occurs if solve(bo) is True, but if I look through the code, the board will only return True if the board is completely solved, so why doesn't this function just lead nowhere since solve(bo) will never be True?</p>
  
  <pre class="lang-py prettyprint-override"><code>def solve(bo):
      find = find_empty(bo)
  
      if not find:
          return True  # This is the only time that solve(bo) == True
      else:
          row, col = find
  
      for i in range(1, 10):
          if valid(bo, i, (row, col)):
              bo[row][col] = i
  
              if solve(bo):
                  return True
  
              bo[row][col] = 0   # Yet here it resets the space to 0 if solve(bo) is False
  
      return False
  
  
  def valid(bo, num, pos):
      for i in range(9):
          if bo[pos[0]][i] == num and pos[1] != i:
              return False
  
      for i in range(9):
          if bo[i][pos[1]] == num and pos[0] != i:
              return False
  
      box_x = (pos[1] // 3) * 3
      box_y = (pos[0] // 3) * 3
  
      for i in range(box_y, box_y + 3):
          for j in range(box_x, box_x + 3):
              if bo[i][j] == num and (i, j) != pos:
                  return False
  
      return True
  
  
  def find_empty(bo):
      for y in range(9):
          for x in range(9):
              if bo[y][x] == 0:
                  return (y, x)
      return False
  </code></pre>