old_contents: """
  This is our hangman game
  """
  
  import words
  import ui
  
  import random
  import sys
  
  difficulty_levels = {
      "easy": {
          'word length': (3, 8),
          'commonality': 1.0,
          'guesses': 15
      },
      "medium": {
          'word length': (8, 15),
          'commonality': 1.0,
          'guesses': 9
      },
      "hard": {
          'word length': (15, 20),
          'commonality': 1.0,
          'guesses': random.randint(4, 6)
      }
  }
  
  
  def main():
      parts = 0
      guess_count = 0
      found = []
      bank = []
  
      user = input("What is your name? ")
      difficulty = input("How hard of a game would you like? {} ".
                         format(list(difficulty_levels.keys())))
  
      while difficulty not in difficulty_levels.keys():
          difficulty = input("How hard of a game would you like? {} ".
                             format(list(difficulty_levels.keys())))
  
      our_word = words.choose(difficulty_levels[difficulty]['word length'])
      print("We picked the word {}".format(our_word))
  
      found = ['i', 's', 'p']
      bank = ['e', 'a', 't', 'o', 'h']
  
      # our_word = words.choose(length=
      # difficulty_levels[difficulty]['word length'])
      # ui.render(object='gallows', parts=0)
      # ui.render(object='game_state', word=our_word, found=found)
      # ui.render(object='bank', letters=bank)
  
  
  def game_loop(word, found, bank, guess_count, parts):
      while True:
          if game_won(word, found):
              print("Yay!")
              sys.exit()
          else:
              ui.render(object='gallows', parts=0)
              ui.render(object='game_state', word=word, found=found)
              ui.render(object='bank', letters=bank)
  
  
  def game_won(word, found):
      for letter in word:
          if letter not in found:
              return False
  
  
  if __name__ == "__main__":
      main()
  
new_contents: """
  This is our hangman game
  """
  
  import words
  import ui
  
  import random
  import sys
  
  difficulty_levels = {
      "easy": {
          'word length': (3, 8),
          'commonality': 1.0,
          'guesses': 15
      },
      "medium": {
          'word length': (8, 15),
          'commonality': 1.0,
          'guesses': 9
      },
      "hard": {
          'word length': (15, 20),
          'commonality': 1.0,
          'guesses': random.randint(4, 6)
      }
  }
  
  FOUND_LETTERS = set()
  WRONG_LETTERS = set()
  
  
  def main():
      user = input("What is your name? ")
      difficulty = input("How hard of a game would you like? {} ".
                         format(list(difficulty_levels.keys())))
  
      while difficulty not in difficulty_levels.keys():
          difficulty = input("How hard of a game would you like? {} ".
                             format(list(difficulty_levels.keys())))
  
      our_word = words.choose(difficulty_levels[difficulty]['word length'])
      game_loop(user, our_word, difficulty_levels[difficulty]['guesses'])
  
  
  def game_loop(user, word, guess_count, parts=None):
      while True:
          if game_won(word, FOUND_LETTERS):
              print("Yay, {}!".format(user))
              sys.exit()
  
          if len(WRONG_LETTERS) >= guess_count:
              print("Oh, sad day, {}. You lost!".format(user))
              sys.exit()
  
          ui.render(object='gallows', parts=0)
          ui.render(object='game_state', word=word, found=FOUND_LETTERS)
          ui.render(object='bank', letters=WRONG_LETTERS)
          guess_letter(word)
  
  
  def guess_letter(word):
      pass
  
  
  
  
  def game_won(word, found):
      for letter in word:
          if letter not in found:
              return False
  
  
  if __name__ == "__main__":
      main()
  
subject: Update main() and game_loop() to use global variables for FOUND_LETTERS and WRONG_LETTERS