The code works, but the result is wrong. It say me: "Oops, try again. median([4, 5, 5, 4]) returned 5.0 instead of 4.5". But the result is 4.5. Sorry, but i can't copy code from codecademy. I try others web browsers but it doesn't work. Assumes that the indentation is Ok.

def median(x):
    result = 0
    longitud = len(x)
    if longitud % 2 == 0:
        middle_value = x[longitud/2]
        middle_value2 = x[(longitud/2)-1]
        result = (middle_value + middle_value2)/2.0
        result = x[longitud/2]
    return result
print median([4,4,5,5])



if you call the function with a unsorted list:

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

it doesn't work, you don't store the result of the sort in a variable, store the result of sort:

x = sorted(x)


OMG! What a stupid mistake. Thanks