A simple command-line Python game where the computer chooses a random number and the player guesses it using higher-or-lower hints.
- Three difficulty levels:
- Easy: 1 to 100
- Medium: 1 to 1,000
- Hard: 1 to 100,000
- Random number selection for every game.
- Higher and lower hints after each wrong guess.
- Attempt counter that shows how many guesses were needed.
- Basic validation for invalid difficulty choices and out-of-range guesses.
- Python 3
- No third-party packages
Open a terminal in this project folder and run:
python main.pyOn Windows, you can also use:
py main.pyWelcome to the Number Guessing Game!
Choose difficulty level
1.Easy(1 - 100)
2.Medium(1 - 1000)
3.Hard(1 - 100000)
Enter difficulty: 1
You have chosen easy level
Guess the number(1 - 100):
Enter your choice: 50
Guess higher!
Enter your choice: 75
Guess lower!
Enter your choice: 63
You guessed it right in 3 attempts!
The hidden number is random, so each playthrough is different.
Number Guessing Game/
|-- main.py # Main game script
`-- README.md # Project documentation
- The game expects numeric input. Entering text will stop the program with an error.
- Decimal inputs are converted to whole numbers.
- Out-of-range guesses do not increase the attempt count.
- The game ends after one successful round.
- Add stronger input validation for non-numeric values.
- Ask the player if they want to play again.
- Add a maximum attempt limit.
- Save the best score for each difficulty level.
- Improve the display formatting for menus and messages.
This project is available for learning, experimentation, and personal use.