Question: I need help with a python code. This program reacts to INCORRECT letters by printing BAD GUESS!. In Hangman, the user only gets 6 incorrect

I need help with a python code. This program reacts to INCORRECT letters by printing BAD GUESS!.

In Hangman, the user only gets 6 incorrect guesses before they lose and the game is over. Write code to implement this.

Rather than hard-coding the answer as hangman, randomly select a word from a LIST of words to use as the answer.

Code:

# Hangman game!

# Assume the answer is "hangman"

A = ['h','a','n','g','m','a','n']

L = ['_','_','_','_','_','_','_']

play = True

while play == True:

#Ask the user to guess a letter

letter = str(input("Guess a letter: "))

# Check to see if that letter is in the answer

i = 0

for currentletter in A:

# If the letter user guessed is found in the answer,

#and if so, end the loop

if A == L:

play = False

print ("GREAT JOB!")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!