I have a nested list like so:
temperature = [["Jan", 12, 18, 16, 18], ["Feb", 10, 20, 50, 50], ["Mar", 23, 32, 10, 32]]
the list contains all the months up until December with the 3 highest temp recorded over the entire month and then the highest out of the 3 appended to the end of the list.
I have worked out the highest temp for each month in the following way:
def sortTemp():
for temp in temperatures:
temp = [temp[0], temp[4]]
highest.append(temp)
highest.sort()
print(highest)
This works, however I had to work out the max values beforehand, and append it to the temperature list as explained above. Is there an easier way to do this?
Also, how do I work out the average temp of each month using the data provided in the temperature list, sorted by the highest average?
Output should be like:
AverageTemp = [["Month", AverageTemp], ["Month", AverageTemp]]