title: Why in this recursive function in Python does the execution continue even after the base condition is met?
body: <p>The Following is a code snippet of a game called Ink Spill from the book 'Make Games with Python &amp; Pygame' by Al Sweigart. (Full Code here: <a href="http://invpy.com/inkspill.py" rel="nofollow noreferrer">http://invpy.com/inkspill.py</a>)</p>
  
  <p>This <strong>recursive function</strong> is responsible  for changing 
  the old color ( in this case '2', which is mainBoard[0][0]) to the new color (in this case '3', which is mainBoard[1][0]) 
  that the player clicks on . </p>
  
  <p><strong>My question is</strong>: In this example why even when the <strong>base condition is 
  met</strong> and the return is executed, <strong>the execution still jumps to the next block</strong> inside the function.</p>
  
  <p>I have tested this with print statements all over the function many times and with different parameters and also on <em>Visualize Code</em> website ...I still don't understand it!</p>
  
  <p>Here, I have deleted many of my print statements and have left just two at the beginning. If you run this code you will see on your console that on the third line the condition is met (3 !=2), but the execution continues!</p>
  
  <p>I really appreciate any help. Thank you very much.</p>
  
  <p><em>And by the way unfortunately, the other question that was asked by someone else: <a href="https://stackoverflow.com/questions/32339236/why-does-this-recursive-function-continue-even-after-its-base-case-has-been-sati">Why does this recursive function continue even after its base case has been satisfied</a> didn't answer my question although very similar!</em></p>
  
  <pre><code>boardWidth = 3
  boardHeight = 3
  mainBoard = [[2, 0, 0], [3, 0, 0], [4, 0, 0]]
  # (blue, red, red),(yellow, red, red),(orange, red, red)
  
  
  def floodFill(board, oldColor, newColor, x, y):
      print(board[x][y], oldColor)
      print(mainBoard)
      if board[x][y] != oldColor:
          return
  
      board[x][y] = newColor  # change the color of the current box
  
      # Make the recursive call for any neighboring boxes:
      if x &gt; 0:
          floodFill(board, oldColor, newColor, x - 1, y)
  
      if x &lt; boardWidth - 1:
          floodFill(board, oldColor, newColor, x + 1, y)
  
      if y &gt; 0:
          floodFill(board, oldColor, newColor, x, y - 1)
  
      if y &lt; boardHeight - 1:
          floodFill(board, oldColor, newColor, x, y + 1)
  
  
  floodFill(mainBoard, 2, 3, 0, 0)
  </code></pre>