title: When to create a nested function inside a function and when to call it from outside?
body: <p>I have seen some code that has these structures.</p>
  <p>Structure 1: An internal function is created within a function</p>
  <pre><code>def external_func(num):
      def internal_func(num2):
          return num2*2
      return internal_func(num + 10)
  
  
  test = external_func(5)
  print(test)
  </code></pre>
  <p>Structure 2: A function is calling another function that is outside itself.</p>
  <pre><code>def _internal_func2(num2):
      return num2 * 2
  
  def external_func2(num):
      return _internal_func2(num + 10)
  
  test2 = external_func2(5)
  print(test2)
  </code></pre>
  <p>For this particular case, both functions provide the same output. Where and why should I use each one of these structures?</p>