Oops, try again.
median([4, 5, 5, 4]) returned 5.0 instead of 4.5 getting this error message but the requirement is to find the median of middle two numbers. In this list the middle two numbers as 5,5 and their average will be 5 then why it is expecting the average as 4.5
need to know why I am getting the above error and what am i doing wrong here
def median(items): length = len(items) if length %2 == 0: firstValue = items[(length/2)-1] secondValue = items[length/2] return (firstValue+secondValue)/2.0 else: middle = length/2 return items[int(middle-1)] print median([4,5,5,4])