import random

# List of words for the game
word_list = ["python", "banana", "guitar", "elephant", "jazz", "oxygen", "unicorn"]

def choose_random_word():
    return random.choice(word_list)

def play_word_guess():
    secret_word = choose_random_word()
    word_length = len(secret_word)
    guessed_letters = []
    attempts = 6  # You can adjust the number of attempts

    print("Welcome to Word Guess!")
    print(f"The word contains {word_length} letters. You have {attempts} attempts to guess it.")

    while attempts > 0:
        display_word = ""
        for letter in secret_word:
            if letter in guessed_letters:
                display_word += letter
            else:
                display_word += "_"

        print("Word:", display_word)
        print("Guessed letters:", guessed_letters)
        print(f"Attempts left: {attempts}")

        guess = input("Guess a letter: ").lower()

        if len(guess) != 1 or not guess.isalpha():
            print("Please enter a single letter.")
            continue

        if guess in guessed_letters:
            print("You've already guessed that letter.")
            continue

        guessed_letters.append(guess)

        if guess in secret_word:
            print("Good guess!")
        else:
            print("Oops! That letter is not in the word.")
            attempts -= 1

        if "_" not in display_word:
            print("Congratulations! You guessed the word:", secret_word)
            break

    else:
        print("Sorry, you're out of attempts. The word was:", secret_word)

if __name__ == "__main__":
    play_word_guess()

Welcome to Word Guess!
The word contains 6 letters. You have 6 attempts to guess it.
Word: ______
Guessed letters: []
Attempts left: 6
Oops! That letter is not in the word.
Word: ______
Guessed letters: ['k']
Attempts left: 5
Oops! That letter is not in the word.
Word: ______
Guessed letters: ['k', 'h']
Attempts left: 4
Good guess!
Word: ____a_
Guessed letters: ['k', 'h', 'a']
Attempts left: 4
Good guess!
Word: __i_a_
Guessed letters: ['k', 'h', 'a', 'i']
Attempts left: 4
Good guess!
Word: __i_ar
Guessed letters: ['k', 'h', 'a', 'i', 'r']
Attempts left: 4
Good guess!
Word: g_i_ar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g']
Attempts left: 4
You've already guessed that letter.
Word: g_i_ar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g']
Attempts left: 4
Good guess!
Word: gui_ar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u']
Attempts left: 4
Good guess!
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
You've already guessed that letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
You've already guessed that letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
You've already guessed that letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4
Please enter a single letter.
Word: guitar
Guessed letters: ['k', 'h', 'a', 'i', 'r', 'g', 'u', 't']
Attempts left: 4