import random HANGMANPICS = [''' +---+ | | | | | | ==========''',''' +---+ | | o | | | | ==========''',''' +---+ | | o | | | | | ==========''',''' +---+ | | o | /| | | | ==========''',''' +---+ | | o | /|\ | | | ==========''',''' +---+ | | o | /|\ | / | | =========''',''' +---+ | | o | /|\ | / \ | | ========'''] words = 'ant baboon badger bat bear beavar camel cat clam cobra cougar coyote crow deer dog donkey duck eagle ferret fox frog goat goose hawk lion lizard llama mole monkey moose mouse mule newt otter owl panda parrot pigeon python rabbit ram rat raven rhino salmon seal shark sheep skunk sloth snake spider stork swan tiger toad trout turkey turtle waesel whale wolf wombat zebra'. split() def getRandomWord(wordlist): #this function returns a random string from the passed list of strings wordIndex = random.randint (0, len(worldist) - 1) return wordList[wordIndex] def displayBoard (HANDGMANGPICS, ,missedLetters, correctLetters,secretWord): print(HANGMANPICS[len(missedLetters)]) print() print (Missed Letters:', end=' ') for letter in missedLetters: print( letter, end='') print() blanks = '_' * len(secretWord) for i in range (len(secretWord)): # replace blanks with correctly guessed letters if secretWord[i] in correctLetters: blanks = blanks[:i] + secretWord[i] + blanks[i+1:] for letter in blanks: # show the secert word with spaces in between each letter print (letter, end_'') print() def getGuess(alreadyGuessed): # return the letter the player enterd. This functions makes sure the player enterd a single letter, and not something else. while true: print('Guess a letter.') guess = input() guess = guess.lower() if len(guess) != 1: print('Please
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question