import random lives = 6 chosen_word = "baboon" print(chosen_word) placeholder = "" word_length = len(chosen_word) for position in range(word_length): placeholder += "_" print("Word to guess: " + placeholder) game_over = False correct_letters = [] while not game_over: print(f"****************************{lives}/6 LIVES LEFT****************************") guess = input("Guess a letter: ").lower() if guess in correct_letters: print(f"You've already guessed {guess}") display = "" for letter in chosen_word: if letter == guess: display += letter correct_letters.append(guess) elif letter in correct_letters: display += letter else: display += "_" print("Word to guess: " + display) if guess not in chosen_word: lives -= 1 print(f"You guessed {guess}, that's not in the word. You lose a life.") if lives == 0: game_over = True print(f"***********************IT WAS {chosen_word}! YOU LOSE**********************") if "_" not in display: game_over = True print("****************************YOU WIN****************************")
baboon Word to guess: ______ ****************************6/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ****************************5/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ****************************4/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ****************************3/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ****************************2/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ****************************1/6 LIVES LEFT**************************** Word to guess: ______ You guessed v, that's not in the word. You lose a life. ***********************IT WAS baboon! YOU LOSE**********************