A command-line number guessing game built in Python. Pick a range, choose a difficulty, and try to guess the computer's randomly selected number within a limited number of attempts.
- Custom guessing range (you choose the start and end)
- Three difficulty levels, each with a different attempt budget
- "Too high" / "too low" feedback after each guess
- Input validation for range, difficulty, and guesses
- Replay loop (play as many rounds as you want without restarting)
- Python 3.10+ (uses
matchstatement)
Run the game from the command line:
python main.pyYou'll be prompted to set a range, then a difficulty:
Enter a range... (eg: 0 10): 1 100
Set game difficulty:
1. Easy
2. Medium
3. Advanced
2
Game difficulty set to Medium.
New game started!
Enter your guess (1-100): 50
Too low!
Remaining attempts: 14
Enter your guess (1-100): 75
Too high!
Remaining attempts: 13
...
| Option | Difficulty | Attempts |
|---|---|---|
| 1 | Easy | 45 |
| 2 | Medium | 15 |
| 3 | Advanced | 5 |
- Enter a numeric range (e.g.
0 10), the start must be smaller than the end. - Choose a difficulty, which sets how many guesses you get.
- Guess the randomly selected number within that range.
- After each wrong guess, you're told whether your guess was too high or too low, and how many attempts remain.
- Guess correctly before running out of attempts to win the round.
- After each round, choose whether to play again, a new random number is picked for each new round, using the same range and difficulty.
- Invalid range: re-prompts if the input isn't two valid numbers, or if the start isn't smaller than the end.
- Invalid difficulty: exits with a message if the input isn't a number or isn't one of the listed options.
- Invalid guess: re-prompts if the guess isn't a valid number or falls outside the selected range.
MIT