I have been messing with this program for my class for days now. I can get the program to run fine....I can get it to return highest value in list but i need it to return the month it occurs in.

Here is the exercise as it appears in my book:
3. Rainfall Statistics
Design a program that lets the user enter the total rainfall for each of the 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts.
and here is the code I have written so far...i have tried everything I can find about list bust cant get it to do what I want:


# Chapter 8 Excercise 3
# This program will calculate the total rainfall for a year as well as the
# average in inches. Also it will display
# the months with the highest and lowest amounts.

print 'This program will calculate the total rainfall for a year as well as the'
print 'average in inches. Also it will display'
print 'the months with the highest and lowest amounts.'
print # This is for spacing output


def main ():
rainfall = rainInput ()
totalRain = totalRainfall (rainfall)
average_Rainfall = averageRainfall (totalRain)
highestMonth = highestMonthNumber (rainfall)
print #this is for spacing output
print 'The total rainfall for the year was: ' +str(totalRain) + ' inche(s)'
print #this is for spacing output
print 'The average rainfall for the year was: ' +str(average_Rainfall) +\
' inche(s)'
print #this is for spacing in output
print 'The highest amount of rain was in' , highestMonth

def rainInput ():
rainfall = ['January','Febuary','March','April','May','June','July','August'\
,'September','October','November','December']
month = 0
while month < len(rainfall):
rainfall[month] = input ('Please enter the amount for month ' + str\
(month + 1) + ': ')
month = month + 1
return rainfall


def totalRainfall (rainfall):
totalRain = 0
month = 0
while month < len(rainfall):
totalRain = rainfall[month] + totalRain
month = month + 1
return totalRain

def averageRainfall (totalRain):
average_Rainfall = totalRain / 12
return average_Rainfall

#Cant figure out this module
def highestMonthNumber (rainfall):
month = ['January','Febuary','March','April','May','June','July','August'\
,'September','October','November','December']

highestMonth = max(rainfall[])
return highestMonth

main ()

PLEASE help this is do by 11:30 and it is already late......

You have to keep in mind that the goal is to get the month, not the amount. To get that, you need to actually iterate through the months where the rainfall occurred, and save the one which had the highest rainfall. That having been said, this version will return both the month and the amount:

def main ():
    rainfall = rainInput ()
    totalRain = totalRainfall (rainfall)
    average_Rainfall = averageRainfall (totalRain)
    highestMonth, highestMonthly = highestMonthNumber (rainfall)
    print #this is for spacing output
    print 'The total rainfall for the year was: ' +str(totalRain) + ' inche(s)'
    print #this is for spacing output
    print 'The average rainfall for the year was: ' +str(average_Rainfall) +\
          ' inche(s)' 
    print #this is for spacing in output
    print 'The highest amount of rain was', highestMonthly, 'in' , highestMonth


def highestMonthNumber (rainfall):
    month = ['January','Febuary','March','April','May','June','July','August'\
                ,'September','October','November','December']
    highestMonthly = 0
    for m, n in enumerate(rainfall):
        if n > highestMonthly:
            highestMonthly = n
            highestMonth = m
    return month[highestMonth], highestMonthly
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.