By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,850 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

Why cannot jump out the loop?

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.