[Tutor] How to skip to next line in for loop

Brain Stormer brnstrmrs at gmail.com
Thu May 1 23:04:08 CEST 2008


I have the following code:

f = open('file.txt',r)
for line in f.read():
     if line == "3":
           line.next
           print line
f.close()

The file.txt looks like
1
2
3
4
5

I would like the code to output "4"

but I don't know how to use the next.  Are there any other way?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080501/b8bfd19f/attachment.htm>


More information about the Tutor mailing list