Hi everyone, I'm currently stuck on the median exercise and I'm not sure why my code isn't working.
I keep getting the error "Oops, try again. median([6, 8, 12, 2, 23]) returned 6 instead of 8" - I assume that its sorting properly so I must've done something wrong I can't find
def median(numbers): newlist = sorted(numbers) n = len(newlist) if n % 2.0 == 1: return newlist[n/2 - 1] if n % 2.0 == 0: return (newlist[n/2] + newlist[n/2 -1])/2.0
Thanks in advance!