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)
A statistics module has been added to python 3.4. It has a function to calculate the average called mean. An example with the list you provided would be:
from statistics import mean l = [15, 18, 2, 36, 12, 78, 5, 6, 9] mean(l)