15/15 help


#1

def median(li):
sorted(li)
if len(li) < 2:
return li[0]
elif len(li) % 2 == 0:
even_return = 0
even_return = even_return + li[len(li) / 2] + li[len(li) / 2 + 1]
even_return = even_return / float(len(li))
return even_return
else:
odd_return = 0
odd_return = odd_return + li[len(li) / 2 - 1]
return odd_return

I have no idea what is wrong. i have been modifying it for 2 hours now :sob:

I have no


#2

Hi @theunicornatihascome,

See the official documentation at:

Is li in a sorted condition after this line is executed?

  sorted(li)

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.