Hello guys, I ran into a weird thing today, the same piece of code returns a value in PyCharm and a different one in the Web application of Code Academy.
this is the code:
def median(l): l.sort() n = len(l) if n % 2 == 1: return (l[int((n / 2) + 0.5)]) else: return ((l[int(n / 2)] + l[int(n / 2 - 1)]) / 2.0) print(median([1, 1, 2]))
Now, in PyCharm this returns “2”.
In the Code Academy Web app it returns “1”.
Obviously, my question is: why ???