15/15 Oops, try again. median([1]) resulted in an error: 'list' object is not callable


#1

Hi,

This is my code

def median(lista):
    lista.sort()
    dim = len(lista)
    location = int(dim / 2)
    if dim % 2 == 0:
        media = (lista[location] + lista[location - 1]) / 2 
        return media
    else:
        media = lista(location)
        return media

but it does not work.

Appears me this " Oops, try again. median([1]) resulted in an error: 'list' object is not callable "

I hope you can help me.

Thanks


#2

@yukardo,

You will have to change your

 media = lista(location)

into

 media = lista[location]