python arbitrarily incrementing an iterator inside a loop

Viewed 41391

I am probably going about this in the wrong manner, but I was wondering how to handle this in python.

First some c code:

int i;

for(i=0;i<100;i++){
  if(i == 50)
    i = i + 10;
  printf("%i\n", i);
}

Ok so we never see the 50's...

My question is, how can I do something similar in python? For instance:

for line in cdata.split('\n'):
  if exp.match(line):
    #increment the position of the iterator by 5?
    pass
  print line

With my limited experience in python, I only have one solution, introduce a counter and another if statement. break the loop until the counter reaches 5 after exp.match(line) is true.

There has got to be a better way to do this, hopefully one that does not involve importing another module.

Thanks in advance!

8 Answers
Related