@lawrenceyy wrote:
So I've found that enumerate does weird things to the index when you don't enumerate from the beginning. How do I force the index to be correct?
Example:
mylist1=range(10,20) mylist2=range(20,30) list1=[] list2=[] #I want to skip the first item for i,j in enumerate(mylist[1:]): list1.append(i) list2.append(j+mylist2[i])
You would expect that list1 contained 1,2,3,4,5,6,7,8,9, but it actually contains 0,1,2,3,4,5,6,7,8. I need the enumerated index to match the index of j in the list or when I try to get mylist2[i], my values will be off my one index. I know that enumerate is working correctly by doing this, but how can I get it to do it the way that I have described?
Posts: 4
Participants: 2