Explore Library
Code QuizIntermediate

Computing the Mean of a Dataset

Finding the off-by-one bug in a function that averages a list of numbers.

Codepython
def mean(data):
    total = sum(data)
    return total / (len(data) - 1)

print(mean([2, 4, 6]))

What is the bug in this mean calculation?