0

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.

kabanus
  • 24,623
  • 6
  • 41
  • 74
mhery
  • 2,097
  • 4
  • 26
  • 35

1 Answers1

2

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
TehTris
  • 3,139
  • 1
  • 21
  • 33
kabanus
  • 24,623
  • 6
  • 41
  • 74