Sorry. You have my cheers. I'm suggesting you to use the python debugger through some GUI ("Eric3" http://www.die-offenbachs.de/detlev/eric3.html for example is a nice and easy to use GUI). It will greatly help you appreciate Python control flow in execution and you will learn a lot more trying to find your bugs that way. It sometimes help to suffer a little. But, of course, I think you will always find an helping hand if needed.
Regards Francis Girard Le lundi 14 FÃvrier 2005 21:58, Chad Everett a ÃcritÂ: > Nope, I am trying to learn it on my own. I am using the book by Michael > Dawson. > > Thanks, > "Francis Girard" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > Mmm. This very much look like a homework from school. Right ? > Francis Girard > > Le lundi 14 Février 2005 04:03, Chad Everett a écrit : > > Hey guys, > > > > Hope you can help me again with another problem. I am trying to learn > > Python on my own and need some help with the following. > > > > I am writing a program that lets has the pc pick a number and the user > > has five guess to get the number. > > 1. BUG: If the number is say 35 and I guess 41 the program tells me > > that I guessed the correct number and tells me I guessed 31. > > > > 2.When I do get the correct number I can not get the program to stop > > asking me for the number. > > > > > > Your help is greatly appreciated. > > > > Chad > > > > # Five Tries to Guess My Number > > # > > # The computer picks a random number between 1 and 100 > > # The player gets Five tries to guess it and the computer lets > > # the player know if the guess is too high, too low > > # or right on the money > > # > > # Chad Everett 2/10/2005 > > > > import random > > > > print "\tWelcome to 'Guess My Number'!" > > print "\nI'm thinking of a number between 1 and 100." > > print "You Only Have Five Guesses.\n" > > > > # set the initial values > > number = random.randrange(100) + 1 > > guess = int(raw_input("Go Ahead and Take a guess: ")) > > tries = 1 > > > > > > # guessing loop > > > > > > while guess != number: > > > > if (guess > number): > > print "Guess Lower..." > > else: > > print "Guess Higher..." > > > > guess = int(raw_input("Take Another guess: ")) > > tries += 1 > > > > print "You guessed it! The number was", number > > print "And it only took you", tries, "tries!\n" > > > > if tries == 5: > > print "Sorry You Lose!!!!" > > print "The Number was ", number > > > > raw_input("\n\nPress the enter key to exit.") > > > > THIS IS WHAT THE RESULTS LOOKS LIKE WHEN I RUN THE PROGRAM > > > > Welcome to 'Guess My Number'! > > > > I'm thinking of a number between 1 and 100. > > You Only Have Five Guesses. > > > > Go Ahead and Take a guess: 99 > > Guess Lower... > > Take Another guess: 98 > > You guessed it! The number was 85 > > And it only took you 2 tries! > > > > Guess Lower... > > Take Another guess: 44 > > You guessed it! The number was 85 > > And it only took you 3 tries! > > > > Guess Higher... > > Take Another guess: 55 > > You guessed it! The number was 85 > > And it only took you 4 tries! > > > > Guess Higher... > > Take Another guess: 33 > > You guessed it! The number was 85 > > And it only took you 5 tries! > > > > Sorry You Lose!!!! > > The Number was 85 > > Guess Higher... > > Take Another guess: -- http://mail.python.org/mailman/listinfo/python-list