Why cannot jump out the loop?

Discussion in 'Python' started by Jinming Xu, Apr 30, 2004.

  1. Jinming Xu

    Jinming Xu Guest

    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
    Jinming Xu, Apr 30, 2004
    #1
    1. Advertising

  2. 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
    =?iso-8859-1?q?Beno=EEt_Dejean?=, Apr 30, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mike
    Replies:
    2
    Views:
    353
    Gordon Beaton
    Sep 8, 2004
  2. Skip Montanaro

    Re: Why cannot jump out the loop?

    Skip Montanaro, Apr 30, 2004, in forum: Python
    Replies:
    0
    Views:
    362
    Skip Montanaro
    Apr 30, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,840
    Smokey Grindel
    Dec 2, 2006
  4. Eadwine Rose
    Replies:
    2
    Views:
    210
    Eadwine Rose
    Oct 15, 2006
  5. Isaac Won
    Replies:
    9
    Views:
    371
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page