title: Understanding for loops and functions
body: <p>I am working on some python homework for a guide I am following, and it is basically wanting to me to make a function that sets up an investment for someone. It would take how much they start with, how much interest is applied, and for how many years they will be investing. Pretty simple... </p>
  
  <p>My hang up is on functions, and the best way to deploy them. As you can see in my code, I have a function set up, but it's not working right, and I didn't even bother calling it. </p>
  
  <p>Instead, I kind of gorilla-ed my way through, and have it outputting what I want it to output, but I KNOW there is an easier way to do what I do. </p>
  
  <p>I attempted to come up with a for loop to do the math from one year of investing to another, but I couldn't figure it out. </p>
  
  <p>Also, I know my indents on lines 11-15 are off, but that's because I have my for loop commented out. The code works just fine without it being commented out as well. </p>
  
  <p>Any help or criticism is welcomed and appreciated! </p>
  
  <pre><code>      #function invest defines initial amount invested, interest, and over how many          years
        def invest(amount, rate, time):
            for amount in invest:
                amount = 5
                print amount
            return
  
  
        mylist = [2000, .025, 5];
        #for growth in "mylist[0, 1, 2]":
            year1 = mylist[0] + (mylist[0] * mylist[1]) 
            year2 = year1 + (year1 * mylist[1])
            year3 = year2 + (year2 * mylist[1])
            year4 = year3 + (year3 * mylist[1])
            year5 = year4 + (year4 * mylist[1])
  
  
  
       #invest(mylist);
       print "prinicpal amount:", mylist[0]
       print "annual rate of return:", mylist[1]
       print "I am going to invest for", mylist[2], "years."
       print
       print "In doing, this I will see the following returns over the next 5 years:"
       print "In the first year, I will see", year1 
       print "In the second year, I will see", year2
       print "In the third year, I will see", year3
       print "In the foruth year, I will see", year4
       print "In the the fifth year, I will see", year5
  </code></pre>