Cant get inner loops to add up properly
<p>My issue is with my user input totals for rainfall not adding up properly</p>

<p>my assumption is that it is not adding the 1st month in when asked on multiple years as </p>

<p><img src="http://i.stack.imgur.com/XKqhg.jpg" alt="problem explained"></p>

<pre><code>def main():

    #define accumulators
    monthRain = 0
    year = 0
    monthTotal = 0
    months = 0
    total = 0 

    #get # of years
    year = int(input("Enter the number of years to collect data for: "))

    #define month total befor it is changed below with year + 1
    monthTotal = year * 12

    #define how many months per year
    months = 12

    #Find average rainfall per month
    for year in range(year):
        #accumulator for rain per month
        total = 0
        #get rainfall per month
        print('\nNext you will enter 12 months of rainfall data for year', year + 1)
        for month in range(months):
            print("Enter the rainfall for month", month + 1, end=" ")
            monthRain = float(input(': '))

            #add monthly raingfall to accumulator
            total += monthRain
            average = total / monthTotal

    #total months of data 
    print('\nYou have entered data for', monthTotal,'months')

    #total rainfall
    print('\nThe total rainfall for the collected months is:', total)
    print('The average monthly rainfall for the collected months is:', format(average, '.2f' ))

main()
</code></pre>

<p>At the start of every year entry, you zero <code>total</code>, then print <code>total</code> at the end. The 64 you see is actually the 2nd year's rainfall, and the 1st year is being thrown out.</p>

python loops nested