Why does my code omit a number from the list?

Please help me understand: Why does my code omit “8” (lst[1])?

print(double_index([3,8,-10,12]) prints [3,-20,12] to the screen instead of [3,8-20,12]. I don’t fully understand why. Can someone explain this to me please?

Here is my code:

#Write your function here
def double_index(lst, index):
list_until_index = lst[:index]
print(list_until_index)
list_after_index = lst[-index+1:]
print(list_after_index)
number_in_question = lst[index]
double_number_in_question = 2 * number_in_question
new_list = list(zip(list_until_index, [double_number_in_question], list_after_index))
if len(lst) > index:
return new_list
else:
return lst

#Uncomment the line below when your function is done
print(double_index([3, 8, -10, 12], 2))

Hello @code3928442758. Welcome to the forum. You’ve created a very complicated function to complete a fairly simple task. No need for slicing and zipping. You can simply change the value of the list element at the index requested, and return the list.

To answer your question, however:

In this line:

new_list = list(zip(list_until_index, [double_number_in_question], list_after_index))

You are using zip() on 3 lists. What are the values of the lists?

list_until_index => [3, 8]
double_number_in_question => [-20]
list_after_index => [12]

So, what happens when you zip() lists of unequal length? Investigate how the zip() method works, and you’ll have your answer.

P.S. You can combine the lists into a new list, but zip() is not the way. Research using the concatenation operator + to merge lists.