# Hangman version 1.0
# Written by: QuantumPhysics
# Date Written: 10/08/12
# import random module
import random
# word-list
x = ["hello","goodbye","test","snow","game","program","bluff","joker",
"steal","computer","draw","match","fake","synthesis","synthetic",
"illusion","coward","cow","mice","mouse","Cplusplus","division",
"match","deuce","trick","image","mirror","hangman","hackers",
"last","thousand","forward","culture","event","public","run"]
# correct guess word list
correct = []
# wrong guess word list
wrong = []
# generate random word
b = random.choice(x)
# gameplay variables
guesses =''
play = 1;
game = ''# main game loop
while play > 0:
# missed = 0, if stays 0 game will be over at end of loop
missed = 0
state = ''
# goto event after end
while len(game) != 1:
# prompts user to input guess
game = raw_input("Please enter your guess: ")
# moves user input to guesses variable
guesses += game
game = ''
# determines whether user input is in word
for letter in b:
if letter in guesses:
# if it is then put letter(s) in place of '-'
state += letter
else:
# if it isn't then draw a '-'
state += '-'
missed += 1
# outputs rephased word and cover
print state
# if to this point missed stay's at 1 then you win
if missed == 0:
print('Correct, you win!')
|