[Tutor] counting in a file

Magnus Lycka magnus@thinkware.se
Sun Nov 17 20:36:03 2002


At 18:54 2002-11-17 -0500, reavey wrote:
>a = 0
>while a<10:
>         new = z.readline().strip()
>         a = a+1

To be honest, I don't understand what you try to do,
but that piece of code is better written as

for a in range(10):
     new = z.readline().strip()

(which seems strange as you overwrite the nine first
values in new with the next line you read in.)


-- 
Magnus Lycka, Thinkware AB
Alvans vag 99, SE-907 50 UMEA, SWEDEN
phone: int+46 70 582 80 65, fax: int+46 70 612 80 65
http://www.thinkware.se/  mailto:magnus@thinkware.se