This is a simple Python-based number guessing game. The program generates a random number between 1 and 100, and the player must guess the number. The program provides feedback for each guess ("Higher!" or "Lower!") until the correct number is guessed. The number of attempts is displayed upon winning.
- Randomly generates a number between 1 and 100.
- Accepts user input for guessing the number.
- Provides feedback ("Higher!" or "Lower!") to guide the user.
- Counts the number of attempts and displays them upon winning.
- Handles invalid input gracefully by prompting the user for valid input.
- Option to play again after finishing a game.
- Python 3.x
- No additional modules are required; the program uses Python's built-in
randommodule.
-
Save the code to a
.pyfile, for example,number_guessing_game.py. -
Open a terminal or command prompt.
-
Run the program with the command:
python number_guessing_game.py