15/15 Median


#1

Hi, I'm getting the error 'median([1]) resulted in an error: 'list' object is not callable' with this code. Can anyone help?

def median(numbers):

snum = []
snum = sorted(numbers)
len_list = len(snum)
odd_median = snum(((len_list+1)/2)-1)

e_middle1 = (len_list/2)
e_middle2 = (e_middle1 -1)
even_median = snum(e_middle1) + snum(e_middle2) / 2.0

if len_list % 2 != 0:
   median_num = odd_median
else:
   median_num = even_median
return median_num

Thanks!


#2

Apologies, just realised that I wasn't using square brackets for accessing the list.