Any ideas as to why this isn't working? I am fairly certain the median is the middle number which i am pretty sure my program returns. Below is my code and the error message I keep getting.
def median(lst): lst.sort() if len(lst) % 2 != 0: return lst[len(lst)/2] else: b = lst[len(lst) / 2 + 1] a = lst[len(lst) / 2] c = (a + b) * .5 return c
Oops, try again. median([6, 8, 12, 2, 23]) returned 12 instead of 8