Well,<br>
I was somewhat confused with all of the answers so I decided to go
with my/following method. Kent's method has 4 fewer lines of
code than mine and cleaner. Please correct me if I am fundamentally wrong. <br>
<br>
f=open('file.txt',r)<br>
<br>
for line in f.read().split():<br>
if line == "3"<br>
position = True<br>
else:<br>
position = False<br>
if position == True<br>
print line<br>
position = False<br>
f.close()<br><br><div class="gmail_quote">On Fri, May 2, 2008 at 6:55 AM, Kent Johnson <<a href="mailto:kent37@tds.net">kent37@tds.net</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Fri, May 2, 2008 at 3:55 AM, Roel Schroeven<br>
<<a href="mailto:rschroev_nospam_ml@fastmail.fm">rschroev_nospam_ml@fastmail.fm</a>> wrote:<br>
<br>
> Shouldn't it even be 'line = f.next()'?<br>
<br>
</div>Wow, I think Brain Stormer should get a prize. I'm not sure what the<br>
prize is, but his short program has elicited incomplete and inaccurate<br>
answers from three of the top posters to this list! I *think* this is<br>
a complete answer:<br>
<div class="Ih2E3d"><br>
f = open('file.txt',r)<br>
</div>for line in f:<br>
if line.rstrip() == "3":<br>
line = f.next()<br>
print line<br>
break # put this in if there is only one line you want to print<br>
f.close()<br>
<br>
...awaiting any further corrections :-)<br>
<font color="#888888">Kent<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Tutor maillist - <a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br>