Quantcast
Channel: Finding the average of a list - Stack Overflow
Viewing all articles
Browse latest Browse all 26

Answer by kindall for Finding the average of a list

$
0
0

Why would you use reduce() for this when Python has a perfectly cromulent sum() function?

print sum(l) / float(len(l))

(The float() is necessary in Python 2 to force Python to do a floating-point division.)


Viewing all articles
Browse latest Browse all 26

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>