Median - Practice Makes Perfect


#1

.

def median(x):
x.sort()
if len(x)%2 == 0:
return (x[len(x)/2] + x[len(x)/2-1])/2.0
else:
return x[(len(x) - 1) / 2]

print median([4,4,5,5])

`


#2

Is there anything you would like to ask about?
BTW, make sure that code is completely intact if your question requires studying your code.