15/15 median, need help



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

i don't know why it returned 0,can you please explain to me what is wrong with my code?

def median(numbers):
    tidy = sorted(numbers)
    if len(tidy) ==1:
        return tidy[0]
    elif len(tidy)%2 ==0:
        mid = len(tidy)/2
        mid_number = tidy[mid-1]/tidy[-mid]
        return mid_number
        mid = (len(tidy)//2)+1
        return tidy[mid]



mid_number = tidy[mid-1]/tidy[-mid]

what is this line suppose to do? And does it fit to use a division operator for this purpose?


it supposes to get the number for the median.
the median located between the tidy[mid-1] and tidy[-mid], so i used division to get the median for the even number list.
is it wrong?


if i have the following list (after sorting):

[4, 4, 5, 5]

the median is the sum of the middle values (4 and 5) divided by 2


lol. I just realized my fault after seeing your reply, it is very embarrassing.
thanks a lot. :joy: