432,275 Members | 947 Online
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

# Michael Dawson's Guess My Number

 P: 3 I am trying to duplicate the Guess My Number Game from Python Programming for the Absolute Beginner by Michael Dawson but for some reason I still cannot figure out my output is not completely correct. The goal of the program is from the computer to pick a number between 1 and 100 and the user to try to guess the number...if the user choses a number that is too high, the computer will tell the user that their guess is too large and if the number is too low the computer will tell the user that their guess is too small and if the guess is correct, the computer should tell the user "You correctly guessed the number that the computer selected ", print the number and display the number of tries....Can you please help? Expand|Select|Wrap|Line Numbers import random print "\tWelcome to 'Guess My Number' !" print "\nI'm thinking of a number between 1 and 100." print "Try to guess it in as few attempts as possible.\n" the_number = random.randrange(100) + 1 guess = int(raw_input("Take a guess: ")) tries = 1 while (guess != the_number):             if (guess > the_number):                 print "The number you guessed is too large"                 guess = int(raw_input("Take a guess: "))                 tries +=1             else:                 print "The number you guessed is too small"                 guess = int(raw_input("Take a guess: "))                 tries +=1                 print "You correctly guessed the number that the computer    selected ", the_number                 print "And it only took you", tries, "tries!\n" raw_input("Press enter to exit")   Oct 18 '08 #1