On 03/10/06, Alan Gilfoy <[EMAIL PROTECTED]> wrote:
>
> for i in range(10):
> > ... break
> > ... else:
> > ... print 'foo'
> > ...
> for i in range(10):
> > ... pass
> > ... else:
> > ... print 'foo'
> > ...
> > foo
>
>
> pardon the newb question, but what do these code lines do
Luke Paireepinart wrote:
> Alan Gilfoy wrote:
>> -code block-
>>
>> number = 3
>> running = True
>>
>> while running:
>>guess = int(raw_input("Please enter a number : ")) #lets user guess a
>> number
>>
>>if guess == number:
>>print "Yay, you got the right number, good for you. But
At 09:49 PM 10/1/2006, Luke Paireepinart wrote:
I had no idea you could have an
'else' tied to a 'while' loop.
Interesting
I looked this up in Python in a Nutshell. From p. 69:
The else Clause on Loop Statements
while and for statements may optionally have a
trailing else clause. The statemen
On 02/10/06, Luke Paireepinart <[EMAIL PROTECTED]> wrote:
> I had no idea you could have an 'else' tied to a 'while' loop.
> Interesting
It allows you to distinguish between exiting the loop via a break and
exiting the loop normally.
eg:
>>> for i in range(10):
... break
... else:
... prin
Alan Gilfoy wrote:
> -code block-
>
> number = 3
> running = True
>
> while running:
>guess = int(raw_input("Please enter a number : ")) #lets user guess a
> number
>
>if guess == number:
>print "Yay, you got the right number, good for you. But you
> don't get any prizes. Do I loo
-code block-
number = 3
running = True
while running:
guess = int(raw_input("Please enter a number : ")) #lets user guess a number
if guess == number:
print "Yay, you got the right number, good for you. But you
don't get any prizes. Do I look like a walking ATM to you?"
runn