import random from hm_noose_art import noose_art_stages, berkeley_binary_noose, noose_art_logo from hm_noose_words import binary_words print(noose_art_logo) def playAgain(): response = input("Would you like to play again? Press 'y' or 'Y' for yes and 'n' or 'N' for now!") if response == 'Y' or response == 'y': hangman_Noose() else: print("Maybe another time. Thanks for playing Hangman's noose!") def hangman_Noose(): game_over = False noose_lives = len(noose_art_stages) - 1 binary_word_choice = random.choice(binary_words) binary_word_size = len(binary_word_choice) noose_display = [] for _ in range(binary_word_size): noose_display += "_" while not game_over: binary_guess = input("Guess a binary letter: ").lower() if binary_guess in noose_display: print(f"You've already guessed the letter {binary_guess}!") for noose_position in range(binary_word_size): binary_letter = binary_word_choice[noose_position] if binary_letter == binary_guess: noose_display[noose_position] = binary_letter print(f"{' '.join(noose_display)}") if binary_guess not in binary_word_choice: print(f"You guessed {binary_guess}, that's not in the word. You lose a life\nby gaining a noose!") noose_lives -= 1 if noose_lives == 0: game_over = True print("You got noosed. No more live, game over!") response = input("Would you like to play again? Press 'y' or 'Y' for yes and 'n' or 'N' for now!") if response == 'Y' or response == 'y': hangman_Noose() else: print("Maybe another time. Thanks for playing Hangman's noose!") if not "_" in noose_display: game_over = True print("You managed not to get noosed!\nCongratulations, you are still alive!") print(noose_art_stages[noose_lives]) if game_over: playAgain() hangman_Noose()