Why cannot jump out the loop?

J

Jinming Xu

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]
i=0
while i<n:
print "i=",i," n=",n
i+=1
-----------------------------------------------------

Thanks in advance!

Jinming

_________________________________________________________________
From must-see cities to the best beaches, plan a getaway with the Spring
Travel Guide! http://special.msn.com/local/springtravel.armx
 
?

=?iso-8859-1?q?Beno=EEt_Dejean?=

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top