Can somebody please explain to me why code doesn't work.
This is my code:
lenght = len(numbers)
if lenght % 2 == 0:
first = numbers[lenght / 2]
second = numbers[first - 1]
even_med = (first + second)/ 2.0
elif lenght % 2 == 1:
odd_med = numbers[(lenght-1)/2]
elif len(numbers) == 1:
I get the following error when I use this code:
Oops, try again. median([4, 5, 5, 4]) resulted in an error: list index out of range
Thank you in advance to anybody who can help.