Why cannot jump out the loop?

Benoît Dejean bnetNOSPAM at ifrance.com
Fri Apr 30 02:02:12 EDT 2004


Le Thu, 29 Apr 2004 21:21:41 -0500, Jinming Xu a écrit :

> Hi Everyone,
> 
> I have a very simple python program, which includes a while loop. But to my 
> surprise,  it cannot jump out the while loop. Does anyone know why?
> 
> Here is the program:
> ___________________________
> #!/usr/bin/env python
> import sys

> n=sys.argv[1]

n = int(sys.argv[1])

> i=0
> while i<n:
>   print "i=",i," n=",n
>   i+=1

ugly C style, better use range

for i in range(int(sys.argv[1])):
	print i



More information about the Python-list mailing list