title: Placing a While-loop Inside a Function
body: <p>I am new to programming and want to place a while-loop inside function so I can call the function. Below is the code I have written. The loop itself works fine, but the list 'numbers' never gets appended when I try putting it in a function.</p>
  
  <pre><code>numbers = []
  
  def loop_function(numbers):
      x = 6
      i = 0
      while i &lt; x:
          print "At the top i is %d" % i
          numbers.append(i)
  
          i = i + 1
          print "Numbers now: ", numbers
          print "At the bottom i is %d\n" % i
  
      return numbers
  
  print "The numbers: " 
  
  for num in numbers:
      print num
  </code></pre>