Median


#1



What is wrong with this code? 


def median(lis):
    lis = sorted(lis)
    median = 0
    if len(lis)%2 == 0:
        median += (lis[len/2] +lis[(len/2)-1])/2
    else:
        median += lis[int(floor(len(lis)/2.0))]
    return median


#2

float before dividing by 2 and see.

Why not just median = lis[(len(lis)-1)/2]?


#3

len() needs a list in the brackets. Otherwise, it doesn't know what it's counting.

len(RandomList)