Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

Number Guessing Game

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.

Features

  • 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)

Requirements

  • Python 3.10+ (uses match statement)

Usage

Run the game from the command line:

python main.py

You'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
...

Difficulty Levels

Option Difficulty Attempts
1 Easy 45
2 Medium 15
3 Advanced 5

How It Works

  1. Enter a numeric range (e.g. 0 10), the start must be smaller than the end.
  2. Choose a difficulty, which sets how many guesses you get.
  3. Guess the randomly selected number within that range.
  4. After each wrong guess, you're told whether your guess was too high or too low, and how many attempts remain.
  5. Guess correctly before running out of attempts to win the round.
  6. After each round, choose whether to play again, a new random number is picked for each new round, using the same range and difficulty.

Error Handling

  • 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.

License

MIT

About

A command-line number guessing game built in Python

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages