I tried this code on and it works. Here it says:
'median([4, 5, 5, 4]) returned 4 instead of 4.5’
pls help

  noofel= len(numbers)
  sort = sorted(numbers)
  med = 0
  if noofel%2 == 0:
    med = (sort[int((noofel-1)/2)] + sort[int((noofel)/2)])/2
    med = sort[int((noofel-1)/2)]
  return med


the problem is that a division which involves two integers:

print 9 / 2 # 4

will be rounded down (floor) to nearest integer. To overcome this problem, this division should involve a float

which version of python did you use on in python3, changes where made to division behavior.


on I use python 3


in python3, changes to division behavior where made, to make it work on python2 (which codecademy uses) the division should involve a float to prevent the rounding down


ok. got it. thank you