How can I skip the current item and the next in a Python loop?
Posted
by uberjumper
on Stack Overflow
See other posts from Stack Overflow
or by uberjumper
Published on 2010-04-07T13:31:53Z
Indexed on
2010/04/07
21:03 UTC
Read the original article
Hit count: 369
This might be a really dumb question, however I've looked around online, etc. And have not seen a solid answer.
Is there a simple way to do something like this?
lines = open('something.txt', 'r').readlines()
for line in lines:
if line == '!':
# force iteration forward twice
line.next().next()
<etc>
It's easy to do in C++; just increment the iterator an extra time. Is there an easy way to do that in Python?
I would just like to point, out the main purpose of this question is not about "reading files and such" and skipping things. I was more looking for C++ iterator style iteration. Also the new title is kinda dumb, and i dont really think it reflects the nature of my question.
© Stack Overflow or respective owner