Median


#1

So it seems to me from looking at these answers that I'm probably trying to over-simplify it. But I'd like to understand why what I have produced doesn't work?

def median(incoming):
    return ( sum(incoming) / len(incoming) )

I'd appreciate your help,

Phil


Practice Makes Perfect - Median
#2

lets say the list is:

[1,2,3,4,100]

the median value is 3, your approach would result in: 110/5, which is 22. Its about getting the middle values, not calculating an average


#3

Oh Yes, Duh.. I'm calculating the Mean. Thanks, and sorry for wasting your time.


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.