0
how to get the index of element of the iterated list directly, without using index()? How to count the instances and not values?
In the "for" loop, does the program "know" the position of the iterated element in the list? I can't use index() method for getting the index because I have a bunch of identical ones and zeros, so I need the way of counting the instances of iterated elements, without checking their values. I think that maybe the "for" loop is already counting the instances or checking the next() element of the list, so I need to get to there. P.S. No, I don't wanna use i=0 ........ i+=1, I know it will work but it is not elegant and efficient way of counting the list
2 Antworten
0
have you considered using a dictionary were you had increasing key value for your elements, you could use that for indexing.
0
i did, but I want to understand the basics of the "for" cycle
also when I search dict index by the value I will find the first one in dict, so you know, it will not help me