input: Write a python function to simulate a Hangman game.
  assert isinstance(play_game(), None)
  assert callable(play_game)
  assert type(play_game()) == type(None)
output: def play_game():
      import random
  
      words = ['python', 'hangman', 'challenge', 'programming', 'function']
      word = random.choice(words)
      guessed_letters = set()
      attempts = 6
      
      def display_word():
          return ' '.join([letter if letter in guessed_letters else '_' for letter in word])
      
      print("Welcome to Hangman!")
      print(display_word())
      
      while attempts > 0:
          guess = input("Guess a letter: ").lower()
          
          if guess in guessed_letters:
              print("You already guessed that letter. Try again.")
          elif guess in word:
              guessed_letters.add(guess)
              print("Good guess!")
          else:
              attempts -= 1
              print(f"Wrong guess. You have {attempts} attempts left.")
          
          print(display_word())
          
          if set(word) == guessed_letters:
              print("Congratulations, you won!")
              return None
      
      print(f"Game over. The word was '{word}'.")