A Byte of Python

The Hangman Gaming Room

Example 4.2. Adding the word to Hangman

#!/usr/bin/env python 
# Filename: hangman2.py 
 
print '''--- Welcome to the Hangman Game ---''' 
# The word that the player has to guess 
word = 'snake' # This is the word that the player has to guess

Output

$ python hangman2.py
--- Welcome to the Hangman Game ---

How It Works

We are now assigning a string to the name word in our program. This will be the word that the player of the game has to guess.