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>Before the print statement, you don't need to add rain value again for rainTotal. This is because grandTotal accounts for the rain per year. And it is being added twice for two years already. So what you're doing is essentially adding the last value of rain twice (2 in this case)
Make your print statement this and remove rainTotal -</p>

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

python nested-loops