Re: Why cannot jump out the loop?
From: Mark McEahern (marklists_at_mceahern.com)
Date: 04/30/04
- Next message: Jinming Xu: "Why cannot jump out the loop?"
- Previous message: Delaney, Timothy C (Timothy): "RE: Why cannot jump out the loop?"
- Next in thread: Skip Montanaro: "Re: Why cannot jump out the loop?"
- Maybe reply: Skip Montanaro: "Re: Why cannot jump out the loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Apr 2004 21:44:33 -0500 To: Jinming Xu <cybermanxu@hotmail.com>
Sorry for top-posting: I just wanted to add that in the OP's case, what
he really needs is for not while.
import sys
n = int(sys.argv[1])
for i in range(n):
print locals()
// m
p.s. Others have already noted that sys.argv returns a sequence of strings.
> Jinming> I have a very simple python program, which includes a while
> Jinming> loop. But to my surprise, it cannot jump out the while
> Jinming> loop. Does anyone know why?
>
> Jinming> Here is the program:
> Jinming> ___________________________
> Jinming> #!/usr/bin/env python
> Jinming> import sys
> Jinming> n=sys.argv[1]
> Jinming> i=0
> Jinming> while i<n:
> Jinming> print "i=",i," n=",n
> Jinming> i+=1
> Jinming> -----------------------------------------------------
>
- Next message: Jinming Xu: "Why cannot jump out the loop?"
- Previous message: Delaney, Timothy C (Timothy): "RE: Why cannot jump out the loop?"
- Next in thread: Skip Montanaro: "Re: Why cannot jump out the loop?"
- Maybe reply: Skip Montanaro: "Re: Why cannot jump out the loop?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|