I have to find the average of a list in Python. This is my code so far
l = [15, 18, 2, 36, 12, 78, 5, 6, 9]
print reduce(lambda x, y: x + y, l)
I've got it so it adds together the values in the list, but I don't know how to make it divide into them?
sum(L) / float(len(L))
. handle empty lists in caller code likeif not L: ...
- n611x007