[Tutor] Help Request: Nested While commands

Paul W Peterson pwpeterson at yahoo.com
Fri Aug 24 16:47:40 CEST 2007

I'm learning Python through the book "Python Programming, Second Edition
for the absolute beginner" by Michael Dawson. In it, he has the program
"Guess my number" (code pasted below). His challenge is to modify the
code so that there are only a limited number of attempts before the
program exits with a chastising message. 

Try as I may, I cannot seem to get the syntax correct for nested while
loops.  I was able to do it with two separate if statements, but this
seems very unelegant to me.  Could you provide a way to achieve this
using nested while statements, or suggest a better use of the ifs? 

Also, while asking for help from this forum: for short pieces of code
such as these, is it appropriate to enter them as inline text, or is it
preferred to have them as attachments? I presume for long pieces of code
the latter applies. 

Thank you

Paul Peterson
Ellicott, Colorado
The Technological Capital of Mid Central Eastern El Paso County,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20070824/a5e5088e/attachment-0001.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: modified_guess_my_ number.py
Type: text/x-python
Size: 993 bytes
Url : http://mail.python.org/pipermail/tutor/attachments/20070824/a5e5088e/attachment-0002.py 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: original_guess_my_ number.py
Type: text/x-python
Size: 850 bytes
Url : http://mail.python.org/pipermail/tutor/attachments/20070824/a5e5088e/attachment-0003.py 

More information about the Tutor mailing list