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)
as a beginner, I just coded this:
L = [15, 18, 2, 36, 12, 78, 5, 6, 9] total = 0 def average(numbers): total = sum(numbers) total = float(total) return total / len(numbers) print average(L)