It is saying "Oops, try again. median([4, 5, 5, 4]) returned 5.0 instead of 4.5"

I am returning 4.5 but its saying it is returning 5

def median(numbers):
    half = len(numbers)/2
    if len(numbers)%2 == 0:
        i = numbers[:half]
        j = numbers[half:]
        total = (i[-1] + j[0])/2.0
        return total
        c = numbers[:half]
        b = numbers[half:]
        return b[0]
numbers = sorted([4,5,5,4])

print median(numbers)

This is working but it is not passing. Can someone explain why?


Remember that a median is taken from the middle of a sorted list.


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