Starting 2nd for loop based on first
<p>I'm trying to write a program that will calculate the future value of a tuition. Tuition today is $10000, with an increase of 5% each year. I am trying to write a program that tells me the cost of tuition in year 10, as well as total tuition for years 10-13 combined. </p>

<p>I am almost certain that I am on the right track with writing 2 for loops, but my program will not run. </p>

<pre><code>def tuition():

    tuition_cost=10000
    increase=1.05
    running_total=0

#first loop includes tuition for years 1-10 
#update tuition for year 10
    for year in range (1,11,1):
        tuition_cost=((tuition_cost*(increase**year))

    print(tuition_cost)

    for year in range (10,14,1):
        tuition_cost=(tuition_cost*(increase**year))
        running_total=running_total+tuition_cost

    print(running_total)

tuition()   
</code></pre>

<p>Does anyone have any suggestions?</p>

<p>Try this one:</p>

<pre><code>def tuition():
    tuition_cost=10000
    increase=1.05

    print('the cost for the year 10:', tuition_cost*(increase**10))

    running_total = 0
    for year in range(10):
        running_total += tuition_cost*(increase**year)

    print('the cost for 10 years:', running_total)

    for year in range(10,14,1):
        running_total += tuition_cost*(increase**year)

    print('the cost for 14 years:', running_total)

tuition()   
</code></pre>

python for-loop nested nested-loops