Respuesta :

Answer:

import random

w1 = ('Hen', 'Cat', 'Elephant', 'Lion')

w2 = random.choice(w1)

correct1 = w2

clue1 = w2[0] + w2[(len(w2)-1):(len(w2))]

guessletter = ''

w2_guess = ''

store1_letter = ''

cnt= 0

limit1 = 5

print('Welcome to "The Game of Word Guessing!"')

print('You will be getting five attempts to guess letter in the word')

print('Let\'s start!')

print('\n')

while cnt < limit1:

   guessletter = input('Guess a letter: ')

   if guessletter in w2:

       print('yes!')

       store1_letter += guessletter

       cnt += 1

   if guessletter not in w1:

       print('no!')

       cnt += 1

   if cnt == 2:

       print('\n')

       clue1 = input('Would you be happy with a clue?')

       if clue1 == 'y':

           print('\n')

           print('CLUE: The 1st and last letter of the word are: ', clue)

       if clue1 == 'n':

           print('You\'re a braveheart!')

print('\n')

print('Now you need to guess. And till now you guessed',len(store1_letter),'letters accurately.')

print('And the letters are: ', store1_letter)

guessword = input('Please guess the whole word now: ')

while guessword:

   if guessword.lower() == correct1:

       print('Congratulations!')

       break

   elif guessword.lower() != correct1:

       print('You are unlucky, the correct answer was,', w2)

       break

print('\n')

input('Click on any letter to exit the Game')

Explanation:

In the above program, the player is first allowed to guess the letter, and then he/she is asked to guess the whole word. The number of attempts is limited to 5. However, the correct word can be guessed only one time. And you need to click any letter to exit the game.