Median error: list indices must be integers not float


Error: Oops, try again. median([1]) resulted in an error: list indices must be integers, not float

I do not understand what i'm doing wrong.

The hint states that we should divide by 2.0 to achieve a float value.

please help!

def median(myList):
    m = sorted(myList)
    listLength = len(m) 
    if listLength % 2 == 0:
        i = listLength/2.0
        med = (m[i] + m[i-1])/2.0
        return med
        i = (listLength-1)/2.0
        med = m[i]
        return med


Just figured out what i was doing wrong.

the value of the indice 'i' was to be calculated as an integer and the median 'med' as a float.
Using i =listLength/2 solved it.