Python 3, increment iterator
I am processing a file line by line. Each line is checked, whether it
contains a given text. Then, the next line needs to be assigned to the
variable
i_line = iter(file)
for i_line in file:
if text in i_line:
#Go to the next line
line = next(i_line, None) #A problem
break
How to increment iterator i_line so as to point to the next line of the
file? Both constructions do not work for me
next(i_line, None)
i_line.next()
No comments:
Post a Comment