Re: Nested structures question

2011-01-13 Thread Jean-Michel Pichavant
Physics Python wrote: Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number betw

Re: Nested structures question

2011-01-12 Thread DevPlayer
looping = True while looping: guess = int(raw_input("Take a guess: ")) tries += 1 if guess > the_number: print "Lower..." elif guess < the_number: print "Higher..." else: print "You guessed it! The number was", the_number print "And it only took y

Re: Nested structures question

2011-01-12 Thread Tim Harig
In case you still need help: - # Set the initial values - the_number= random.randrange(100) + 1 - tries = 0 - guess = None - - # Guessing loop - while guess != the_number and tries < 7: - guess = int(raw_input("Take a guess: ")) - if guess > the_number: - print "Lower..." -

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Jason Staudenmayer wrote: > Return False instead of break should work > > else: > print "You guessed it! The number was", the_number > print "And it only took you", tries, "tries!\n" > return False Since he isn't in a function, that isn't any good. He wo

Re: Nested structures question

2011-01-12 Thread Tim Harig
[wrapped lines to <80 characters per RFC 1855] On 2011-01-12, Physics Python wrote: > Is this an indentation problem then? That depends how you look at it. I was not clear from your code exactly where you wanted to handle things. > How do I update the sentinel within the secondary while loop. I

RE: Nested structures question

2011-01-12 Thread Jason Staudenmayer
gt; python-list-bounces+jasons=adventureaquarium@python.org > [mailto:python-list-bounces+jasons=adventureaquarium@pytho > n.org] On Behalf Of Physics Python > Sent: Wednesday, January 12, 2011 2:53 PM > To: python-list@python.org > Subject: Re: Nested structures question >

Re: Nested structures question

2011-01-12 Thread Physics Python
Thanks, Is this an indentation problem then? How do I update the sentinel within the secondary while loop. I am trying to avoid using breaks by the way, as I can program this example using breaks: --- start--- import random print "\tWelcome to 'Guess my number'!:" print "\nI'm thinking of a numb

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Physics Python wrote: > while guess != the_number: = > while tries > 7: > if guess > the_number: > print "Lower..." > else: > print "Higher..." > guess = int(raw_input("Take a guess:

Nested structures question

2011-01-12 Thread Physics Python
Hello, I am teaching myself python using the book: Python Programming for Absolute Beginners, 2nd edition by Michael Dawson. I am using python 2.7.1. In chapter 3 we are learning to use structures (while, if, elif) to write a program that has the user guess a number between 1 and 100. Here is