title: Where is the new value created from the for loop stored?
body: <p>I am trying to get my head around the following function and for loop: </p>
  
  <pre><code>def invest(amount, rate, time):
      print ("Principal amount: ${}" .format(amount))
      print ("Annual rate of return: {}" .format(rate))
      for t in range(1, 9):
          amount = amount * (1 + rate)
          print ("Year {}: ${}" .format(t, amount))
  
  invest(100, .05, 8)
  invest(2000, 0.025, 5)
  </code></pre>
  
  <p>As I understand it the amount of 100 is passed into the function and the for loop calculated the rate of return. This increases the value of the amount to 105.0. However, what I am struggling to understand is where this amount is stored? Is it stored in the function or within the for loop? On the second loop the amount of 105.0 is used, but where does it take this figure from?</p>
  
  <p>A second code example of a similar issue is with the following:</p>
  
  <pre><code>def doubles(number):    
      number = number * 2 
      return number       
  
  my_num = 3          
  for n in range(0, 3):   
      my_num = doubles(my_num)     
      print (my_num)
  </code></pre>
  
  <p>The for loop takes the number 3 from the my_num variable and passes it to the function which mulitplies it by 2. The number is returned and printed in the for loop. On the second loop it takes the number 6 and passes it to the function. Where is the value of 6 stored? Has it updated the variable, is it held in the for loop or the function?</p>
  
  <p>Thanks. </p>