Appearance
CS101 Word Game: Python Hangman
python
import pythonhangman.MyWordGame as wg
words = wg.WGLib.parseWordsFile('lowerwords.txt')
wg.startSession(words)Brief Description
This game prompts user to guess letters of a concealed word. Their score is based on their ability to uncover the word in a given number of guesses.
Settings:
Word source: lowerwords.txt Word length: randomly selected to be 4–6 letters each game. Scoring: 1 point for a win, 0 for a loss. A session reports games played, highest score, and average score.
Rules of Play
Goal: Reveal the secret word by guessing letters. Displays each turn: The word with underscores for unknown letters (e.g., _pp_e), Letters you’ve already guessed (e.g., a, e, p), Your current count of wrong guesses (e.g., 2/6) Valid input: a single alphabetic letter (a–z); Input is case-insensitive. No repeats: a letter already guessed is invalid. Any non-letter or multi-character input is invalid. For an invalid input, the game prints “Invalid input” and reprompts. Turn outcome: If the letter is in the secret word, all matching underscores are revealed. If the letter is not in the word, your wrong-guess count increases by 1. Win condition: all letters revealed before reaching 6 wrong guesses → You win (score = 1). Lose condition: you reach 6 wrong guesses with unrevealed letters → You lose (score = 0). Play again: after each game, enter y to start a new game or n to end the session.