Created
April 28, 2015 00:34
-
-
Save jamie23/c866a719b39d89581ed8 to your computer and use it in GitHub Desktop.
Very quick hangman game to teach primary school kids in 1 hour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Making a hangman game, woohoo | |
#Get input and convert to list | |
word = raw_input("Please input your word: "); | |
word = list(word); | |
guesses = 5; | |
#Setting up our hashes list | |
guessingWord = len(word)*["*"]; | |
while(guesses>0): | |
guessLetter = raw_input("Please enter a char to guess: "); | |
for i in range(0,len(word)): | |
if(word[i]==guessLetter): | |
guessingWord[i]=guessLetter; | |
if not "*" in guessingWord: | |
break; | |
print ''.join(guessingWord); | |
guesses = guesses-1; | |
#Output as a string | |
if guesses>0: | |
print("You have won the game!!!"); | |
else: | |
print("Sorry but you ran out of guesses, the correct answer was: "); | |
print ''.join(word); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment