import random
import gamename
import hangmanpics
import wordslist
print(gamename.hangman_log)
word_choice = random.choice(wordslist.random_words)
print(word_choice)
word_length = len(word_choice)
display = []
lives = 0
for letter in word_choice:
display += “_”
print(”.join(display))
end_game = False
while not end_game:
user_guess = input(“Guess a letter in word: “)
for position in range(word_length):
letter = word_choice[position]
if user_guess == letter:
#lives -= 1
display[position] = letter
if user_guess != letter:
lives += 1
print(hangmanpics.HANGMANPICS[lives])
if lives == 6:
end_game = True
print("You lost")
print(f"the word is{word}")
if "_" not in display:
end_game = True
print('You won')
word = ''.join(display)
print(f"The word is {word}")
hey everyone i’m working on this hangman project but i’m having a problem with adding lives only when the user guess is not in the word and also print the hangman pics when its the user’s entry in not in the word choice but if the letter in the letter guessed it shouldn’t add lives or print hangman pics how do i do it i would apreciate your help
Felonzo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.