Reputation: 2248
I have two lists in Python
, like this:
RG = [30, 30, 30, 50, 50, 50, 70, 70, 80, 80, 80]
EC = [2, 2, 2, 25, 25, 25, 30, 30, 10, 10, 10]
and I want to iterate over then with an auxiliar variable, like i
, because when some condition is met (like EC is different of RG), I want that this iteration go to another element that it's not the next one. Like:
for i in ?:
// code
if EC != RG:
i = i + 5;
// code
I already saw zip function, but I didn't found how to do this using it, because this function
is an iterable
.
Upvotes: 0
Views: 471
Reputation: 25980
A for loop is not useful if you do not want to iterate a container while jumping indices. In this case a while would be more conducive to your task:
i = 0
while i < len(RG):
# code
if EC[i] != RG[i]:
i += 5;
else: i += 1
# code
Upvotes: 2