A simple and fun number guessing game built in Python where users try to guess a randomly selected number within a given range and limited number of attempts — based on the chosen difficulty level. A simple yet engaging command-line number guessing game with adjustable difficulty levels and smart feedback!
- 3 Difficulty Modes
Easy (1-20), Medium (1-50), Hard (1-100) with different guess limits - Smart Hints 🔍
Tells you to guess higher/lower after each attempt - Input Validation 🛡️
- 3 invalid input allowance
- Instant quit option with
q
- Clear error messages
- Game Statistics 📊
Shows total attempts and final number at game end
- Requirements: Python 3.x
- Download: Save code as
number_guessing_game.py
- Run:
python number_guessing_game.py or python3 number 6EBF _guessing_game.py
-
Choose Difficulty
- Easy (1-20, 5 guesses)
- Medium (1-50, 7 guesses)
- Hard (1-100, 6 guesses) Enter 1 for Easy, 2 for Medium, or 3 for Hard:
-
Guess Smartly
- You get 5-7 attempts based on difficulty
- Type numbers between 1 and your mode's maximum
- Get higher/lower hints after each guess
-
Special Commands
q
: Quit anytime- Invalid inputs tracked (3 strikes)
-
Win/Lose Conditions
- Correct guess within attempts ➡️ Victory! 🏆
- Exceed guesses/invalid inputs ➡️ Revealed number 😉
while True: level = input("1/2/3...")
num = random.randint(1, max_num)
while guess_count < max_guesses: # Input handling with 'q' support # Hints system # Win/lose checks `
Found a bug? Want new features?
- Fork the repo
- Create your branch
- Submit PR!
Made with ❤️ by Syed Afaq Gilani | Try it now and beat the odds! 🚀