Sometimes, we want to find the average of a list with Python.
In this article, we’ll look at how to find the average of a list with Python.
How to find the average of a list with Python?
To find the average of a list with Python, we can use the statistics.mean
method.
For instance, we write
l = [15, 18, 2, 36, 12, 78, 5, 6, 9]
import statistics
avg = statistics.mean(l)
to call statistics.mean
with list l
to compute the mean of the numbers in the list l
.
Conclusion
To find the average of a list with Python, we can use the statistics.mean
method.