The code works, but is it any good? Or is the code way to complecated? I am a little bit sceptical

def median (numlist):
    sl = sorted(numlist)
    indexmid = (len(numlist)-1)/2
    indexodd1 = len(numlist)/2
    indexodd2 = (indexodd1)-1
    if len(numlist)%2 == 0:
        return ((sl[indexodd1] + sl[indexodd2]) / 2.0)
        return sl[indexmid]
liste= [1,4,3,2,5,7,6]
print median(liste)


Maybe with a google search, you'll find discussions/opinions
python median from list


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