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

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Physics Python physicsandpyt...@gmail.com wrote: while guess != the_number: = while tries 7: if guess the_number: print Lower... else: print Higher... guess =

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 number

RE: Nested structures question

2011-01-12 Thread Jason Staudenmayer
@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 Thanks, Is this an indentation problem then? How do I update the sentinel

Re: Nested structures question

2011-01-12 Thread Tim Harig
[wrapped lines to 80 characters per RFC 1855] On 2011-01-12, Physics Python physicsandpyt...@gmail.com 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

Re: Nested structures question

2011-01-12 Thread Tim Harig
On 2011-01-12, Jason Staudenmayer jas...@adventureaquarium.com 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

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... - elif

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 you, tries,