How do I find the arithmetic mean of a list in Python? For example:
[1, 2, 3, 4] ⟶ 2.5
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For Python 3.8+, use
statistics.fmeanfor numerical stability with floats. (Fast.)For Python 3.4+, use
statistics.meanfor numerical stability with floats. (Slower.)For older versions of Python 3, use
For Python 2, convert
lento a float to get float division: