Median need some help


#1

it give me that error
Oops, try again. median([4, 5, 5, 4]) returned 4 instead of 4.5

https://www.codecademy.com/en/courses/python-intermediate-en-rCQKw/2/5?curriculum_id=4f89dab3d788890003000096

def median (lst):
    lst.sort()
    y = len(lst)
    medue = 0
    if  y% 2 == 0 :
        medue = (lst[y/2-1] + lst[y/2]) /2
    else : 
        medue = lst[y/2]
    return medue


#2

i have found the issue
in that line
medue = (lst[y/2-1] + lst[y/2]) /2
we will make a small change we will add "2.0" like the to make the medue float
medue = (lst[y/2-1] + lst[y/2]) /2.0


#3

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