title: Even after "if" condition is met, how come "else" code is still running
body: <p>In the below code, how come "result = n * recurse" is executed even when n==0. Shouldn't the else statement be ignored once if statement is executed. In other words, how come both the code give the same output? </p>
  
  <p>My understanding is that in the first code once n==0, if condition is met so else statements won't be executed. Thus there should be no "returning 1" onwards print in the output for the first code.</p>
  
  <pre><code>def factorial(n):
      space = ' ' * (4 * n)
      print(space, 'factorial', n)
      if n == 0:
          print(space, 'returning 1')
          return 1
      else:
          recurse = factorial(n-1)
          result = n * recurse
          print(space, 'returning', result)
          return result
  
  def factorial(n):
      space = ' ' * (4 * n)
      print(space, 'factorial', n)
      if n == 0:
          print(space, 'returning 1')
          return 1
      else:
          recurse = factorial(n-1)
      result = n * recurse
      print(space, 'returning', result)
      return result
  
  factorial (4)
  
  
  
  Both the codes gives the same result:
               factorial 4
           factorial 3
       factorial 2
    factorial 1
  factorial 0
  returning 1
   returning 1
       returning 2
           returning 6
               returning 24
  </code></pre>