15. Median



median([1]) resulted in an error: list indices must be integers, not float

I really need help here, would apreciate it alot, hope u can take the time.

def median(lizt):
    w = sorted(lizt)
    x = len(w)
    if x % 2 == 0:
        med_firstIndex = int(x /2.0)
        med_secondIndex = [med_firstIndex -1]
        total_even = (w[med_firstIndex] + w[med_secondIndex])/2.0
        return total_even
        median_firstIndex = x/2.0
    total_odd = w[median_firstIndex]
    return total_odd



        median_firstIndex = x/2.0

median_fistIndex will be a float, indexes should be integers instead


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