Median - Practice makes perfect


Please, help! I am stuck (again) in the Median excercise:

I tried to make all outcome integers by using "int", but the comment still says:
"Oops, try again. median([1]) returned [1] instead of 1'

Can you help me discover what I am not doing the right way in my code:

#I will be using floor and ceil, so I import Math
from math import *
def median(numbers):
    #I sort the numbers
    return numbers
    #I try to find out if the sequence is uneven
    if len(numbers)%2!=0:
        """In case of an uneven sequence, I can take the middle number"""
        return w
    elif len(numbers)==1:
        """In case of an uneven sequence of 1 number, I can take that number"""
        u = int(numbers[0])
        return u
        """Here I try to find the number left and right of the middle"""
        return z


This will explain the error message. All that is returned in the original list, sorted.


Thank you, mtf!! After some other issues I had to tackle I made it! :tada: Thanks!!!


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