Tried to look at other forums but not quite sure what I have done with my code!

Any help explaining what I have done? I am given the error message "median([1]) resulted in an error: list index out of range"

My code is:

def median(numbers)

numbers=sorted(numbers)

count=len(numbers)

if count % 2 != 0:

return numbers [count % 2]

else:

num1 = numbers [(count-1) %2]

num2 = numbers [(count) %2]

return (num1+num2) % 2

Thanks!