[Tutor] re Format a file

John Fouhy john at fouhy.net
Fri Feb 27 05:53:48 CET 2009


2009/2/27 prasad rao <prasadaraon50 at gmail.com>:
> Hello
> I don't know why, but this I think going into infinite loop.
> I cant see anything wrong in it.
> Please show me where  the problem is.
[...]
> ???????? while len(line)>60:
> ????????????tem=line[60:]
> ????????????try:
> ??????????????? a,b=tem.split(' ',1)
> ??????????????? de.write(line[:60]+a+'\n')
> ??????????????? line=b
> ????????????except ValueError:pass

So you have a while loop, whose condition depends on line.

This will loop infinitely if the body of the loop does not change the
value of line.

Can you see how that could happen?

-- 
John.


More information about the Tutor mailing list