Hi, I have a f question. So I have came up with this function:
if len(lst)%2 == 1:
if len(lst)%2 == 0:
half = int(len(lst)/2)
second_half = lst[half:]
mdl_avg = (first_half + second_half)/2
Now, I know the function is weird and not ideal at all. But I don’t actually understand what results in the error I get:
When I print(middle_element([5, 2, -10, -4, 4, 5])) I do get result -7.0 as supposed and I do not get any error in the console on the right, but the website tells me at the bottom “list index out of range” and marks excercise as failed. Why?