EDIT: I got it! Needed to set num_list as sorted list.
Oops, try again. median([4, 5, 5, 4]) returned 5.0 instead of 4.5
I don't think the sorted function is working correctly, not sure if I implemented that wrong. But if I add 2 more numbers to the end of the list it will return 4.5, which is the average of the 4 and 5 that would then be the middle of the list.
def median(num_list): sorted(num_list) pos1 = len(num_list) / 2 pos2 = pos1 - 1 if len(num_list) % 2 == 0: return float(num_list[pos1]+num_list[pos2])/2 else: return float(num_list[pos1]) print median([4,5,5,4])