This is the code I wrote:
def median(numbers): l = sorted(numbers) count = 0 for x in l: count += 1 while count > 2: del l del l[count-2] count -= 2 if count == 2: return (l + l) / 2 else: n = l return n
Here on codecademy I get the error: median([4, 5, 5, 4]) returned 4 instead of 4.5
But when I try this In PyCharm I get 4.5
When I try the solution in PyCharm, I get this error: TypeError: list indices must be integers or slices, not float
I have python 3.6 on my PC.
Is one of them bugged or are the different python versions to blame?