Question: Problem 4 : Guess the Number Game Write a program that allows the user to guess a randomly generated number within a specified range. Use

Problem4: Guess the Number Game
Write a program that allows the user to guess a randomly generated number within a specified range.
Use the random module to generate a random integer between 1 and 100.
Create a function guess_number(target) that repeatedly asks the user to guess the number until they guess correctly. Provide hints if the guess is too high or too low.
Keep track of the number of attempts and display it once the user guesses the number.
Guess the number: 50
Output: Too high!
Guess the number: 25
Output: Too low!
Guess the number: 37
Output: Correct! It took you 3 attempts.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!