How do I modify this program player has 5 chances to ask a letter is in the word. Computer responds yes and no.
Original Exercise - Computer picks a random word from a list and player guesses the word. Computer tells the player how many letters are in the word. Then the player gets 5 chances to ask whether letter is in the word. Computer responds yes and no after the 5 chances player must guess the word. Unfortunately I screwed up I got the random part and how many letters in the word. I am able to check the letters in the words higher or lower value,but how do I do it in a way that computer will check and respond back yes and no whether the letter is in the word plus I have to do it 5 tries before player must guess the word.
import random # list of words words = ['python', 'jumble', 'easy', "difficult", "answer", "tracer", "muffin"] # Computer picks one word from the list word = random.choice(words) # create a variable to use later to see if the guess is correct correct = word print "Guess the word hint there are :", len(word) print "letters" guess = raw_input("\nYour guess:") guess = guess.lower() while (guess !=correct) and (guess !=""): if guess > word: print "Lower letter.." elif guess < word: print "Higher letter.." else: print "You guessed it correctly" guess = raw_input("\nYour guess:") guess = guess.lower() if guess == correct: print "That's it! You guessed it!\n" print "Thanks for playing." raw_input("\n\nPress the enter key to exit.")