from __future__ import print_function
import random
HANGMANPICS = ['''

  +---+
  |   |
      |
      |
      |
      |
=========''', '''

  +---+
  |   |
  O   |
      |
      |
      |
=========''', '''

  +---+
  |   |
  O   |
  |   |
      |
      |
=========''', '''

  +---+
  |   |
  O   |
 /|   |
      |
      |
=========''', '''

  +---+
  |   |
  O   |
 /|\  |
      |
      |
=========''', '''

  +---+
  |   |
  O   |
 /|\  |
 /    |
      |
=========''', '''

  +---+
  |   |
  O   |
 /|\  |
 / \  |
      |
=========''']
words = ('ant baboon badger bat bear beaver 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 weasel whale wolf '
         'wombat zebra ').split()

class Hangman:
    def __init__(self, words):
        self.missedLetters = ' '
        self.correctLetters = ' '
        self.secretWord = self.getRandomWord(words)
        self.gameIsDone = False

        print('H A N G M A N')

    def getRandomWord(self, wordList):
        # This function returns a random string from the passed list of strings.
        wordIndex = random.randint(0, len(wordList) - 1)
        return wordList[wordIndex]

    def displayBoard(self, HANGMANPICS):
        print(HANGMANPICS[len(self.missedLetters)])
        print()

        print('Missed letters:', end=' ')
        for letter in self.missedLetters:
            print(letter, end=' ')
        print()

        blanks = '_' * len(self.secretWord)

        # replace blanks with correctly guessed letters
        for i in range(len(self.secretWord)):
            if self.secretWord[i] in self.correctLetters:
                blanks = blanks[:i] + self.secretWord[i] + blanks[i+1:]

        # show the secret word with spaces in between each letter
        for letter in blanks:
            print(letter, end=' ')
        print()


    # Returns the letter the player entered. This function makes
    # sure the player entered a single letter, and not something else.
    def getGuess(self, alreadyGuessed):
        while True:
            print('Guess a letter.')
            guess = input()
            guess = guess.lower()
            if len(guess) != 1:
                print('Please enter a single letter.')
            elif guess in alreadyGuessed:
                print('You have already guessed that letter. Choose again.')
            elif guess not in 'abcdefghijklmnopqrstuvwxyz':
                print('Please enter a LETTER.')
            else:
                return guess


    def checkWin(self):
        for i in range(len(self.secretWord)):
            if self.secretWord[i] not in self.correctLetters:
                return False
        print('Yes! The secret word is "' + self.secretWord + '"! You have won!')
        return True


    def checkLost(self, HANGMANPICS):
        if len(self.missedLetters) == len(HANGMANPICS) - 1:
            self.displayBoard(HANGMANPICS)
            print('You have run out of guesses!')
            print('After ' + str(len(self.missedLetters)) + ' missed guesses and ' +
                  str(len(self.correctLetters)) + ' correct guesses, the word was "' +
                  self.secretWord + '"')
            return True


def playAgain():
    # This function returns True if the player wants to play again,
    # otherwise it returns False.
    print('Do you want to play again? (yes or no)')
    return input().lower().startswith('y')


def main():
    missedLetters, correctLetters, secretWord, gameIsDone = init(words)

    while True:
        displayBoard(HANGMANPICS, missedLetters, correctLetters, secretWord)

        # Let the player type in a letter.
        guess = getGuess(missedLetters + correctLetters)

        if guess in secretWord:
            correctLetters = correctLetters + guess

            # Check if the player has won
            foundAllLetters = gameIsDone = checkWin(secretWord, correctLetters)
        else:
            missedLetters = missedLetters + guess

            # Check if player has guessed too many times and lost
            gameIsDone = checkLost(HANGMANPICS, missedLetters,
                                   correctLetters, secretWord)

            # Ask the player if they want to play again
            # (but only if the game is done).
        if gameIsDone:
            if playAgain():
                (missedLetters, correctLetters,
                 secretWord, gameIsDone) = init(words)
            else:
                break

if __name__ == "__main__":
    main()

@@ -3845,68 +3845,29 @@
     
-missedLetters, correctLetters, secretWord, gameIsDone = init
+currentGame = Hangman
 (wor
@@ -3898,16 +3898,28 @@
         
+currentGame.
 displayB
@@ -3938,51 +3938,8 @@
 PICS
-, missedLetters, correctLetters, secretWord
 )%0D%0A%0D
@@ -3999,25 +3999,49 @@
 guess = 
-getGuess(
+currentGame.getGuess(currentGame.
 missedLe
@@ -4048,16 +4048,28 @@
 tters + 
+currentGame.
 correctL
@@ -4099,16 +4099,28 @@
 uess in 
+currentGame.
 secretWo
@@ -4128,32 +4128,44 @@
 d:%0D%0A            
+currentGame.
 correctLetters =
@@ -4165,16 +4165,28 @@
 tters = 
+currentGame.
 correctL
@@ -4262,74 +4262,54 @@
     
-foundAllLetters = gameIsDone = checkWin(secretWord, correctLetters
+currentGame.gameIsDone = currentGame.checkWin(
 )%0D%0A 
@@ -4334,16 +4334,28 @@
         
+currentGame.
 missedLe
@@ -4362,16 +4362,28 @@
 tters = 
+currentGame.
 missedLe
@@ -4478,16 +4478,28 @@
         
+currentGame.
 gameIsDo
@@ -4503,16 +4503,28 @@
 sDone = 
+currentGame.
 checkLos
@@ -4540,87 +4540,8 @@
 PICS
-, missedLetters,%0D%0A                                   correctLetters, secretWord
 )%0D%0A%0D
@@ -4656,16 +4656,28 @@
      if 
+currentGame.
 gameIsDo
@@ -4730,88 +4730,29 @@
     
-(missedLetters, correctLetters,%0D%0A                 secretWord, gameIsDone) = init
+currentGame = Hangman
 (wor

Modify main() to use the Hangman class