╔═══════════════════════════════════════╗
║ 🎯 GUESS THE NUMBER! ║
║ ║
║ 🤔 Think of a number 1 to 5... ║
║ 💡 You have 5 attempts ║
║ 🔼 Too High? Try lower! ║
║ 🔽 Too Low? Try higher! ║
║ ✅ Correct? You Win! ║
╚═══════════════════════════════════════╝
A fun Python CLI game where you guess a random number with hints and attempt tracking!
A beginner-friendly Python project that demonstrates the use of loops, conditionals, random numbers, and user input — all in one fun game!
The computer secretly picks a random number between 1 and 5. Your job is to guess it in 5 tries or less using hints after each guess.
| Feature | Description |
|---|---|
| 🎲 Random Number | Picks a new number every game |
| 💬 Smart Hints | Tells you if guess is too high or too low |
| 🔢 Attempt Counter | Tracks how many guesses you've used |
| ⏳ Guess Limit | Only 5 chances — don't waste them! |
| 🏆 Win Message | Shows how many tries it took to win |
| ❌ Lose Message | Reveals the answer if you run out |
- Python 3.x installed → Download Python
Step 1 — Clone the repository
git clone https://github.com/HaiderNeuralNet/NumberGuessGame.gitStep 2 — Go into the folder
cd NumberGuessGameStep 3 — Run the game
python main.py1. Run the program
2. A random number between 1–5 is chosen secretly
3. Type your guess and press Enter
4. Read the hint:
🔼 "too high" → guess a smaller number
🔽 "too low" → guess a bigger number
✅ "right!" → you win!
5. You have 5 total attempts
6. If you don't guess it — the answer is revealed!
🎮 NUMBER GUESSING GAME
━━━━━━━━━━━━━━━━━━━━━━━
enter your guess:
>>> 3
too low
Guesses left: 4
━━━━━━━━━━━━━━━━━━━━━━━
enter your guess:
>>> 4
too low
Guesses left: 3
━━━━━━━━━━━━━━━━━━━━━━━
enter your guess:
>>> 5
✅ right in 3 tries!
━━━━━━━━━━━━━━━━━━━━━━━
📦 NumberGuessGame
┣ 📜 main.py ← main game file
┗ 📜 README.md ← you are here!
- ✅ Using Python
randommodule - ✅
whileloops with conditions - ✅
if / elif / elselogic - ✅ Taking user input with
input() - ✅ f-strings for formatted output
- ✅ Breaking out of loops with
break
- Add difficulty levels (Easy / Medium / Hard)
- Wider number range (1–100)
- Score leaderboard
- GUI version with Tkinter
- Play again option
⭐ If you liked this project, please give it a star! ⭐
Made by Haider Ali Shah