How to pull info from a string and output it?
Question: I have to create a game where the computer picks a random word and the player
has to guess that word. The computer tells the player how many letters are in
the word. Then the player gets five chances to ask if a letter is in the word.
The computer can only respond with `"yes"` or `"no"`. Then, the player must
guess the word. I only have:

    
    
    import random
    WORDS = ("python", "jumble", "easy", "difficult", "answer", "xylophone", "truck" , "doom" , "mayonase" ,"flying" ,"magic" ,"mine" ,"bugle")
    word = random.choice(WORDS)
    print(len(word))
    correct = word
    guess = input("\nYour guess: ")
    if guess != correct and guess != "" :
            print("No.")
    
    if guess == correct:
        print("Yes!\n") 
    

I have no idea how to do this problem.


Answer: I assume you want to let the user ask the computer if a letter is in the word,
5 times. If so, here is the code:

    
    
    for i in range(5): #Let the player ask 5 times
        letter = input("What letter do you want to ask about? ")[0]
        #take only the 1st letter if they try to cheat
    
        if letter in correct:
            print("yes, letter is in word\n")
        else:
            print("no, letter is not in word")
    

The key is the `in` operator within the `for` loop.

