CodeAlpha Python Programming Internship | Task 1
A text-based Hangman game where the player guesses a word one letter at a time, with a maximum of 6 incorrect guesses.
| File | Purpose |
|---|---|
main.py |
Main game script |
No external libraries needed. Uses only built-in Python modules.
python main.py
- A random word is selected from 5 predefined words
- Guess one letter at a time
- Correct guess — letter is revealed in the word
- Wrong guess — hangman drawing progresses
- You win by guessing all letters before 6 wrong guesses
- You lose when the hangman is complete (6 wrong guesses)
-----
| |
O |
/|\ |
|
|
=========
Word: _ _ _ _ _ _
Wrong guesses (4/6): a, e, i, o
Enter a letter:
random— randomly selects a word from the listwhile loop— keeps the game running until win or lossif-else— checks if guessed letter is correct or wrongstrings— word and letter comparisonlists— predefined word list