[Tutor] breaking the 'while' loop

Andre Engels andreengels at gmail.com
Tue Mar 20 16:25:59 CET 2007


2007/3/20, Alexander Kapshuk <akap at isd.dp.ua>:
>
>  Dear All,
>
>
>
> I have been learning computer programming with Python only for a short
> while. I have a question to do with breaking the *while loop*.
>
>
>
> I have attached the source code of a program called 'Guess my number' with
> the *while loop* running until the right number is guessed.
>
>
>
> I want to limit the number of tries to 5. To do that, I have tried the *if
> structure* along with the *break statement* immediately below the
>
> 'tries += 1' line:
>
>
>
> if tries > 5:
>
>           break
>
>  print "Wrong guess!"
>
>
>
> Which still did not result in the *while loop* breaking after attempt No
> 5.
>
>
>
> I would appreciate being explained what I am doing wrong.
>
It would have helped if you had given the code *with* the extra lines in it.
My first guess is that you did a wrong indentation, but without the actual
code I cannot be sure.

-- 
Andre Engels, andreengels at gmail.com
ICQ: 6260644  --  Skype: a_engels
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070320/26d766f2/attachment.html 


More information about the Tutor mailing list