Python 2.4 | 7.3 The for statement
Ron_Adam
radam2 at tampabay.rr.com
Fri Mar 25 13:29:16 EST 2005
More information about the Python-list mailing list
Fri Mar 25 13:29:16 EST 2005
- Previous message (by thread): Python 2.4 | 7.3 The for statement
- Next message (by thread): Python 2.4 | 7.3 The for statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
>-- Your code
>foo = 0
>for item1 in range(10):
> for item2 in range(10):
> foo = item1 + item2
> if foo == 2:
> print "Let's see"
> break # let's go
> if (item1 + item2) == 2:
> break # one more time
>print foo
The outer loop never reaches 1, so we can get rid of it along with the
second if statement, the additions aren't needed either.
So what you have left is this.
for foo in range(3):
pass
print "Let's see"
print foo
Which is the same as:
print "let's see\n", foo
I know that isn't the point. Just couldn't resist. ;)
Ron_Adam
- Previous message (by thread): Python 2.4 | 7.3 The for statement
- Next message (by thread): Python 2.4 | 7.3 The for statement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list