What does index of lst even mean?

Thank you @appylpye! Now it makes sense. One of the reasons I didn’t understand was because I overlooked the “:” after “+1”.

But why do we need to go through all these to understand this concept? I honestly think Code Academy need to review her lesson material and the order with which the challenges come. I am getting so frustrated by the day. Yet, despite complaint from all corners, there is no change. Why not save the institution the rigor of trying to explain over and over again? why not save the students the time to try to read bunch of comments, get confused, understand, get confuse again etc? The easier way is always better. I hope i will eventually understand after reading comment for hours!!! SMH

Question 1
Can you please point to where there is any lesson on how to double index before now? It is possible that some of us actually missed it. Thank you

**Question 2**
With reference to the below code (as copied from codeacademy solution), Can anyone please help me to understand this code and explain it in a very simple terms. I can see the reason wht i should have >= after the "if" statement. Why not just ">". Why do we need to have   new_lst = new_lst + lst[index+1:].....what exactly is the + operator doing here?

def double_index(lst, index):
  if index >= len(lst):
    return lst
    new_lst = lst[0:index]
    new_lst = new_lst + lst[index+1:]
    return new_lst

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

I do not doubt the quality of the code and i am pretty sure that my confusion is due to the yet low level of my understanding of python, I will however appreciate codeacademy look into its material and help strugglers like me understand better. The essence of learning is to know and not to get confused and demotivated

The above code is adding to the list, rather than accessing the value at the supplied index position, doubling the value, then assigning it back to that position.

 lst[index] *= 2


lst[index] = lst[index] * 2


[3, 8, -10, 12]
    index =  2

lst[index] *= 2

[3, 8, -20, 12]
   value at index is doubled
1 Like

No one should be mad at you at all. You are doing exceptionally well to help the students. Most are frustrated with the method codeacademy uses. I honestly think what we are going through in this lesson can be avoided. You will realize that you go through the stress of explaining over and over again. Trust me and for fact, not all student will read all comments here. So, you might continue to get questions you have already answered. Again mtf, you have been exceptional and we can do better here. If most are complaining and yet there is nothing from codeacademy to effect some corrections, then it seems strange


Hello @sodiqolabodeafolayan.

I doubt there is a lesson that specifically covers doubling an element at a specific index in a list, but you presumably have learned about lists before encountering this challenge. Accessing an element of a list by its index should be familiar to you. All this challenge is asking us to do, is locate the element at the index specified by the index parameter, and double its value.

As to the Codecademy solution, it builds a new list in three parts. First it takes a slice of the original list up to the specified index, then it appends the doubled value of the element at the specified index, then it uses + to concatenate the slice of the original list from right after the specified index through the end of the list.

    new_lst = lst[0:index] #slice of the beginning of the list up to the index specified
    new_lst.append(lst[index]*2) #append the doubled value of the element at the specified index
    new_lst = new_lst + lst[index+1:] #concatenate the remaining elements from the original list
    return new_lst #return the new list

In the code you posted, the list has 4 elements. That means len(lst) is 4, but the index values are 0, 1, 2, 3. There is no element at index 4, so if the index is greater than or equal to the length of the list, we return the original list.

Thank you for the explanation.


What I find odd is that if index is a gray area of understanding, then list slicing would be even more cryptic. There is some incongruency, here.

I’ve mentioned in the past that the issue may stem from the name of the function…


This implies that it is the INDEX that is doubled, not the value AT that index.


would be less ambiguous.

As far as this problem having gotten any review, such as confirming that list indices, accessing values by index and mutating a list by accessing, changing, and replacing values, as well as other list operations are well explained, I can neither confirm nor deny said review.

Until such time as said review/revision takes place we are left to deal with each learner in turn, and try to suss out what they do understand, and what not. Yes, it means answering the same question multiple times, but that is my choice. I could just pass the question over and leave the learner to keep digging.


mtf, you are an absolute gem. A big hug. I have learnt patience and the willingness to always want to give helping hand. At this stage i have a fair understanding of the concept but i wont leave until i am 100% satisfied.

Thank you mtf and all the codeacademy team


Thank you so much for actually going line by line through the solution. I have read all the comments/replies here and was no further ahead in understanding what the code in the solution was actually doing. I was frustrated that I was not grasping it. Even putting the code through the visual python utility (http://pythontutor.com/visualize.html#mode=display) did not assist my understanding.

Your explanation is what I needed, so many thanks!

1 Like

Nope, you did not miss anything. There is a flaw in the course progression.

8 posts were split to a new topic: Code Challenge: Lists - Double Index

Well that explains the problem. None of that was taught to me in the class. I quadruple checked all of my notes (which are really shadow copies of EVERYTHING that I’ve been taught) - not one piece of that info was in there.

Referring this to @lilybird for further investigation.

1 Like

def double_index(lst, index):
if index >= len(lst):
return lst
lst[index] *= 2
return lst

I have solved this challenge with the code above. However, I have a question regarding the code.

  1. if index >= len(lst):

Why is the assignment operator >= ? Python is xero-indexed, but I do not understand what is being executed.

Because if the index is not less than the length, it is out of range. That means equal or greater.

Wow, thank you for responding so quickly! Sorry about my late response, I was at my grandparents for the Thanksgiving Break and grandma bans electronics. I understand this concept now.

1 Like

Who would argue with Gran? The vittles are more than enough reward!

I’ve created a ticket for our Curriculum Team to audit this code challenge. I will report back here once I get an update. Thanks for flagging the issue.


I just want to add that CodeAcademy jumps around in their curriculum when a person subscribes to a certain track like “Computer Science,” rather than if a person had selected Python as their one track. As someone who is a beginner to CS and Python, I think this selection of problems is a little advanced. There was definitely a learning curve spike from the last project I was working on, and it doesn’t help that the prompt is confusing and hard to follow.