why is this not working?

def median(n):
    if len(x) == 1:
        median = x[0]
    elif len(x) % 2 ==0:
        median = (x[len(n)/2]+x[(len(n)/2)-1])/2
        median = x[(len(n)-1)/2]
    return median


dividing an integer by an integer will result in a integer, if needs be, the number is floored. You will need to do something with float


to get a float median, using:
float(n)/2 or n/(2.0)


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