Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Why cannot jump out the loop?

Reply
Thread Tools

Why cannot jump out the loop?

 
 
Jinming Xu
Guest
Posts: n/a
 
      04-30-2004
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


 
Reply With Quote
 
 
 
 
=?iso-8859-1?q?Beno=EEt_Dejean?=
Guest
Posts: n/a
 
      04-30-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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot jump to new part of Silverlight video when using handler Roger Martin ASP .Net 17 12-18-2008 02:00 AM
why why why why why Mr. SweatyFinger ASP .Net 4 12-21-2006 01:15 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Double left click jump to top, same with ctrl or shift to jump to bottom? Eadwine Rose Javascript 2 10-15-2006 08:38 PM
Re: Why cannot jump out the loop? Skip Montanaro Python 0 04-30-2004 02:34 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57