Posted On: Saturday, January 14, 2017 at 9:21 AM Last updated: Saturday, January 14, 2017 at 9:32 AM
import time
name = raw_input("Hello what is your name? ")
print "Hello, " + name, "ready to play hangman!"
print " "
print "Start guessing..."
#here we set the secret
word = "secret"
#creates an empty variable
guesses = ''
#determine the number of turns
turns = 10
# Create a while loop
#check if the turns are more than zero
while turns > 0:
# make a counter that starts with zero
failed = 0
# for every character in secret_word
for char in word:
# see if the character is in the players guess
if char in guesses:
# print then out the character
print char,
else:
# if not found, print a dash
print "_",
# and increase the failed counter with one
failed += 1
# if failed is equal to zero
# print You Won
if failed == 0:
print "
You won"
# exit the script
break
# ask the user go guess a character
guess = raw_input("guess a character:")
# set the players guess to guesses
guesses += guess