A simple command-line Number Guessing Game built in Python. The program randomly selects a number between 1 and 5, and the player has three chances to guess it correctly.
Run the script in your terminal or IDE.
You’ll be greeted with a welcome message.
Guess an integer between 1 and 5.
You have 3 attempts. If your guess matches the random number, you win!
If you run out of guesses, the game ends, and you can restart to play again.
Welcome to the number guessing game Guesses Left: 3 Guess an integer between 1 and 5: 4 Better Luck next time! Guesses Left: 2 Guess an integer between 1 and 5: 3 congratulations, you win! the game is over. Restart the program to play again!
Python 3.x
Run the game:
python guessing_game.py
This project is open-source and available under the MIT License.
Credit: University of Galway Foundamental of Python notes.