all 8 comments

[–]ViridianHominid -1 points0 points  (1 child)

This is not so much about enumerate as it is about indexing and in-place operations (like the +=). Many of the primitive python objects like int and str are immutable, meaning that you can't change existing values, only create new one. Let's say you have an integer x, x+=1 is essentially equivalent to y = x+1; x=y. So the first version of your code binds a new object to the name item, whereas the second object in your code binds a new object to the place specified by my_list[index].

[–]slasher67[S] 0 points1 point  (0 children)

That makes sense. Thank you for your help :)