[Tutor] Guess my number game
myles broomes
mylesbroomes at hotmail.co.uk
Sat Nov 19 13:53:40 CET 2011
I am currently learning Python from the 'Python Programming for the Absolute Beginner' book. At the end of each chapter, you are given challenges and one of the challenges is to make a 'Guess My Number' game where the player thinks of a number between 1 and 100 and the computer has to guess the number. I'm having real trouble designing the 'guessing loop' where the computer guesses the players number. Here is the pseudocode I have written up:
Welcome the user to the game
Explain the rules of the game
Wait for the user to think of a number
Once the user has thought of their number, take a guess
While the number has not been guessed correctly
Increase the number of 'tries' by 1
Ask the user if the guess was too high or too low
If the guess was too high
guess lower
If the guess was too low
guess higher
Once the number has been guessed correctly, tell the user the number of tries it took
Exit the game
Any help would be very much appreciated.
More information about the Tutor
mailing list