I keep getting the following error:
Oops, try again. median([4, 5, 5, 4]) returned 4 instead of 4.5
So for debugging reasons, I've tried to see what values my individual arguments would return.
The following line will return 5 (which is what I expect it to return)
However, dividing this argument by 2, will somehow result in 2 being returned instead of 2.5.
I tried making this a float but then it will just return the value 2.0.
So now I'm kinda stuck just wondering what kind of sorcery this is
def median(x): x = sorted(x) if len(x) == 1: return x elif len(x) % 2 != 0: return x[(len(x)/2)-0.5] else: return ( x[(len(x)/2)] + x[(len(x)/2)-1] )/2