- Project Description
- Installation Instructions
- Usage Instructions
- File Structure
- License Information
Hangman is a classic word guessing game. This project is a Python implementation of the game. The aim of this project is to provide a fun and interactive way to play Hangman in the console. The game starts with a default number of lives and a random word from a provided list. The user guesses one letter at a time, with the goal of guessing the entire word. This project helped me learn about handling user input, working with strings and lists, and structuring a program using classes and methods.
To install and run this project:
- Clone the repository or download the files.
- Ensure you have Python installed on your machine.
- Run the script using a Python interpreter.
- To run the script write 'python milestone_5.py' in the command line
To play the game:
- Run the script.
- When prompted, enter a single letter to guess a letter in the word.
- Continue guessing letters until you've guessed the entire word or you've run out of lives.
The project has the following structure:
README.md
: This is the readme file that explains everything to do with this repomilestone_2.py
: Initial script that looked at picking a word randomly from a list and taking a user input for the lettermilestone_3.py
: This script moved on to creating the functions for the user guess and establishing if it was correct, a single letter. It also included the first version of the function for checking the guess.milestone_4.py
: This script moved on to then set up the class and include the function to set up the attributes for the game.milestone_5.py
: This is the main Python script that you run to play the game. It contains the Hangman class and the logic for running the game. It builds on the previous milestones to combine functions in theHangman
class. This includes__init__
which sets up the attributes for the gam,check_guess
to see if the letter that has been guessed is in the word,ask_for_input
this asks for the users input and checks it is a single letter. The functionplay_game
is then set which runs the game and will determine if the player loses or wins. The final if statement allows the game to run when themilestone_5.py
is run in the command line. Theword_list
parameter can be adjust before playing to change the words that might be selected in the game.
This project is licensed under the MIT License. See the LICENSE file for details.