Skip to main content

7.12) Exercise 19 - Guess The Number Game


Write a game in which the user has to guess a number (integer) from 0 to 10 (or a bigger range to make it harder).
Level 1: Make the computer generate a random integer and keep requesting a number until the user guesses it.
Level 2: Make the computer tell the player whether the number they're trying to guess is higher or lower than the one they just entered.
Level 3: Improve your code to return a different message if the number is out of the range from which the integer was drawn.
Hint: To generate a random integer between a and b, use the function randint(a,b) from the module random.
Solution: challenge_guess_the_number_solution.py