Practice Makes Perfect 15 - Median


#1

Please help with this code

def median(numbers):
    sorted(numbers)
    if len(numbers) % 2 == 0:
        return ((numbers[len(numbers) / 2]) + (numbers[len(numbers) / 2] - 1)) / 2
    else:
        return numbers[len(numbers) / 2]

error: Oops, try again. median([4, 5, 5, 4]) returned 4 instead of 4.5


#2

Do float operation. Divide by 2.0 instead of 2.