Median


#1





Oops, try again. median([4, 5, 5, 4]) returned 4.0 instead of 4.5

I expect the using half and other half will give me the two center numbers. I then use them to call those numbers and average them.

def median(numbers):
    sort=sorted(numbers)
    even = (len(numbers)%2)
    if even == 0:
        half = (len(sort)/2)
        otherhalf = ((len(sort)/2)-1)
        middle= float((sort[half] + sort[otherhalf])/2)
    else:
        middle = sort[len(sort)/2]
    return middle


#2

currently first the division happens:

9 / 2

so then the number will be divided and floored, and then cast to a float. You will need to change where float gets applied


#4

I moved the float to each inside the division - thanks.


#5