read lines

Piet van Oostrum piet at cs.uu.nl
Tue Dec 4 08:36:13 EST 2007


>>>>> Horacius ReX <horacius.rex at gmail.com> (HR) wrote:

>HR> while 1:
>HR>          line = infile1.readline()

You have an infinite loop. Fortunately your program stops because of the
error. When you encounter end of file, line becomes the empty string and
the split gives you only 1 item instead of 2.

So add the following:
         if not line: break

Also your choice for 0 as initial values of minimum and maximum isn't good.

-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list