def display_hangman(errors):
    stages = [
        """
           -----
           |   |
               |
               |
               |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
               |
               |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
           |   |
               |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
          /|   |
               |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
          /|\\  |
               |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
          /|\\  |
          /    |
               |
        --------
        """,
        """
           -----
           |   |
           O   |
          /|\\  |
          / \\  |
               |
        --------
        """
    ]
    print(stages[errors])

def play_hangman(word):
    word = word.upper()
    guessed = "_" * len(word)
    word_letters = set(word)
    guessed_letters = set()
    attempts = 6
    correct_guesses = set()

    print("¡Bienvenido al juego del ahorcado!")
    display_hangman(6 - attempts)
    print("Palabra: " + guessed)

    while attempts > 0 and len(correct_guesses) < len(word_letters):
        guess = input("Adivina una letra: ").upper()

        if guess in guessed_letters:
            print("Ya has intentado con esa letra. Intenta de nuevo.")
        elif guess in word_letters:
            print(f"¡Bien hecho! {guess} está en la palabra.")
            correct_guesses.add(guess)
            guessed_letters.add(guess)
            guessed = "".join([letter if letter in correct_guesses or letter == " " else "_" for letter in word])
        else:
            print(f"{guess} no está en la palabra.")
            attempts -= 1
            guessed_letters.add(guess)
            display_hangman(6 - attempts)

        print("Palabra: " + guessed)

    if len(correct_guesses) == len(word_letters):
        print(f"¡Felicidades! Has adivinado la palabra '{word}' correctamente.")
    else:
        print(f"Lo siento, has perdido. La palabra era '{word}'.")

if __name__ == "__main__":
    word_to_guess = "SE CONSCIENTE DE TUS EMOCIONES"
    play_hangman(word_to_guess)
Shopping Cart
Scroll to Top