title: UnboundLocalError: local variable 'f' referenced before assignment
body: <p>I have python function:</p>
  
  <p><strong>FactorialFunction.py</strong></p>
  
  <pre><code>def factorial(n):
      if n == 0:
          return 1
          f = n * factorial(n-1)
      print(f)
      return(f)
      factorial(4)
  </code></pre>
  
  <p>shows nothing, when I run it in terminal</p>
  
  <p><a href="https://i.stack.imgur.com/sxsbJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sxsbJ.png" alt="enter image description here"></a></p>
  
  <p>but when I run it in python shell get <strong>"UnboundLocalError: local variable 'f' referenced before assignment"</strong></p>
  
  <p><a href="https://i.stack.imgur.com/A14Wh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/A14Wh.png" alt="enter image description here"></a></p>