Obviously im missing something, the median returns [1] instead of 1 what makes me think im right there but i cant see it, plese help

In the mean while ill keep trying

Replace this line with your code.


Looks like you might have written a return statement like this...

return [s[n]]

Please show us your code.


@mtf , thanks for the reply, here is y code, also the link on the top goes to it

def median(numbers):

numbers = sorted(numbers)

if len(numbers) == 1:
    index = numbers
    return index

elif len(numbers) % 2 == 0:
    index1 = len(numbers) / 2
    index2 = index1 - 1
    index = (index2 + index1)/2.0
    return index

    index = len(numbers) / 2.0
    return index


This return value will be [1] since you effectively returning the list.

The remaining code is also incorrect as it focuses on the indexes, not the element values.


@mtf thank you for that


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