[Tutor] Iterating through objects
Alan Gauld
alan.gauld at btinternet.com
Sun Aug 16 21:06:54 CEST 2009
"GoodPotatoes" <goodpotatoes at yahoo.com> wrote
> print page1.readlines()
>
>>From this excercise, the first time I read page1 I get all of the lines.
The best thing to do is store them in a variable then print them.
That way you can access them at will:
lines = page1.readlines()
print lines # all of them as a list
print lines[2],lines[5], lines [-1] # 3rd, 6th and last as lines
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list