How can I skip the current item and the next in a Python loop?
- by uberjumper
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.