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.)
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.)