2025 Number Guessing Game

Goal: create a Python guessing game that does the following:
1. asks the player for their name.
2. creates a number within a specific range by using code like: number = (random.randrange(1,100))
3. asks them to guess a number within that range.
Example code: number = (random.randrange(1,100)) generates a number between 0 and 99.
4. compares the guess to the actual number.
-if they are right, congratulate them!
-if the guess is too low, the program says “too low” and asks them to guess again.
-if the guess is too high, the program says “too high” and asks them to guess again.
5. uses a function to let the player keep guessing until they guess the correct number.

HINTS:
1. use a function to allow the player to make a second guess if they are wrong on the first try. Click here for refresher on functions.

2. let’s talk about generating the random number – copy paste this into a new program in the codehs sandbox:

import random
number=(random.randrange(0,100))

Here’s some very brief starter code:

Here’s what the output will look like: