15/15


#1

def median(numbers):
lst = sorted(numbers)
if len(numbers)%2==0:
median=(lst[len(lst)/2-1]+lst[len(lst)/2+1])/(2.0)
elif len(numbers)%2==1:
median=lst[(len(lst)+1)/2]
elif len(numbers)==1:
median=lst[0]
return median

it gives me the message is "Oops, try again. median([1]) resulted in an error: list index out of range". I don't understand where I am wrong? Thank you in advance


#2

for this block

elif len(numbers)%2==1:
    median=lst[(len(lst)+1)/2]

try

    elif len(numbers)%2==1:
        median=lst[(len(lst)/2)]

and remove this block its unecessaary

elif len(numbers)==1:
median=lst[0]