find median value in list
I would like to give some feedback about task of finding median value in list.
In Spyder using Python 3.5 the below code works perfectly:
def checkio(data): return sorted(data)[round(len(data)/2)] if (len(data) % 2 == 1) \ else (sorted(data) [int(len(data)/2 - 1)] + sorted(data)[int(len(data)/2)]) / 2.0
I get the right value: 49999.5 for this test: checkio(list(range(100000)))
But checkio says that this code returns with 6.
Thank you!
From: https://checkio.org/mission/median/solve/
HTTP_USER_AGENT:
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:46.0) Gecko/20100101 Firefox/46.0