# 15/15 My code is having problems sorting the list

#1

My code here throws the error "Oops, try again. median([6, 8, 12, 2, 23]) returned 12 instead of 8"

I think there might be a problem with the sorting but even after I tinkered with it I'm still having trouble

``````def median(some_list):
sort_list = list(some_list)
if len(sort_list) % 2 == 0:
return ((sort_list[len(sort_list)/2] + sort_list[(len(sort_list)/2) + 1])/2.0)
else:
return sort_list[(len(sort_list)/2) + int(0.5)]
print median([4,5,5,4])``````

#2

From what I see, you never actually sort the list. You can simply do the following

``````lst = [2, 1, 3, 5, 9, 7]
print(sorted(lst))``````

#3

i changed my line of code from
"""
sort_list = list(some_list)
"""
to
"""
sort_list = sorted(some_list)
"""'
and i get a new error where it says
"Oops, try again. median([1]) resulted in an error: list indices must be integers, not float"

#4

This is your issue, do the following

``[int((len(sort_list)/2.0))]``

That way it is an int 100% of the time.