Andrew N. - 1 year ago 120
Python Question

# Python lists and function, finding the max/min months of rainfall

My program is supposed to take the rainfall amounts for each month and calculate the total rainfall for the year, the average monthly rainfall, and the months with the highest(max) and lowest(min) rainfall amounts.

Everything works as planned, except for the highest and lowest month outputs. I need for this to display the name of the months with the highest and lowest rainfall amounts. I can get the correct values to display, just not the name of the month.

``````months = ["January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"]
values = []
year = []

for i in months :
values.append(float(input("Enter total rain for " + i + ": ")))
print()

def total():
print("The total rainfall for the year is %.2f" % sum(values))
total()

def average():
print("The average monthly rainfall is %.2f" % float(sum(values)/ 12))
average()

def highest():
print("The highest monthly rainfall is", max(values))
highest()

def lowest():
print("The lowest monthly rainfall is", min(values))
lowest()
``````

``````def highest():