Nested Loops calculation output is incorrect, but program runs
<p>How am I able to get my program to display year 1 for the first 12 months and then year 2 for the next 12 months if the input value for years = 2?</p>

<p>Also I don't know where my calculation is going wrong. According to my desired output, the total rainfall output should be 37, but I am getting 39.</p>

<p><a href="http://i.stack.imgur.com/YgaH7.png" rel="nofollow"><img src="http://i.stack.imgur.com/YgaH7.png" alt="Added picture of current output. Total should be at 37 not 39. I also need the second batch of 12 months to say year 2"></a></p>

<pre><code>#the following are the values for input:
#year 1 month 1 THROUGH year 1 month 11 = 1
#year 1 month 12 THROUGH year 2 month 12 = 2

def main():
    #desired year = 2
    years = int(input("Enter the number of years you want the rainfall calculator to determine: "))
    calcRainFall(years)

def calcRainFall(yearsF):
    months = 12
    grandTotal = 0.0

    for years_rain in range(yearsF):
        total= 0.0
        for month in range(months):
            print('Enter the number of inches of rainfall for year 1 month', month + 1, end='')
            rain = int(input(': '))
            total += rain
        grandTotal += total
    #This is not giving me the total I need. output should be 37.
    #rainTotal = rain + grandTotal
    #print("The total amount of inches of rainfall for 2 year(s), is", rainTotal)
    print("The total amount of inches of rainfall for 2 year(s), is", grandTotal)
main()
</code></pre>

<p>Notes for your code:</p>

<p>As stated earlier, rainTotal is unneeded.</p>

<p>You can try:      </p>

<pre><code>print 'Enter the number of inches of rainfall for year %d month %d' % (years_rain, month), end='')
</code></pre>

<p>This will fill the first %d for the value for years_rain and the second %d with the value for month as your for loops run. </p>

<p>This trick can also be used on the final print line as shown below:</p>

<pre><code>print("The total amount of inches of rainfall for %d year(s) % yearsF, is", grandTotal)
</code></pre>

python nested-loops