#Hangmanfrom time import sleepimport randomfrom hangman_parts import parts#Prints a hangman pictureprint("Welcome to Hangman")print(' ', '------')print(' ', '| |')print(' ', '| O')print(' ', '| -|-')print(' ', '| |')print(' ', '| / \\')print('------------')print('Let me think of a word')#Wait time functiondef wait(): for i in range(5): print('.', end = "") sleep(.5) print() wait()#List of wordswords = ['mouse', 'cat', 'fish', 'robot', 'computer']picked = random.choice(words)print("Okay Ive got it!")print("The word has", len(picked), "letters")for i in range(len(picked)): print('_',' ', end = "") print()#Creates a list with _ marks for lettersright = ['_'] * len(picked) wrong = []#Prints letters in right with _'sdef add_letter(): for i in right: print(i, ' ', end = "") print()#Prints out wrong lettersdef wrong_letter(): print("Wrong letters:", end = "") for i in wrong: print(i,' ',end = "") print()#Main Loop while True: print('=====================') guess = input("Guess a letter")if guess in picked: print("Let me check") right[picked.index(guess)] = guess wait() add_letter() wrong_letter() parts(len(wrong))elif guess not in picked: print("Let me check") wait() if guess in wrong: print("You already guessed", guess) wrong_letter() else: print(guess, "is not in my word") wrong.append(guess) add_letter() wrong_letter() parts(len(wrong))if len(wrong) > 4: print("Game Over!") print("I picked", picked) breakif '_' not in right: print("You guessed it!") print("I picked", picked) break#Main Loop while True: print('=====================') guess = input("Guess a letter") if guess in picked: print("Let me check") right[picked.index(guess)] = guess wait() add_letter() wrong_letter() parts(len(wrong)) elif guess not in picked: print("Let me check") wait() if guess in wrong: print("You already guessed", guess) wrong_letter() else: print(guess, "is not in my word") wrong.append(guess) add_letter() wrong_letter() parts(len(wrong)) if len(wrong) > 4: print("Game Over!") print("I picked", picked) break if '_' not in right: print("You guessed it!") print("I picked", picked) breakdef parts(x): if x == 0: print(' ', '------') print(' ', '| |') print(' ', '| ') print(' ', '| ') print(' ', '| ') print(' ', '| ') print('------------') if x == 1: print(' ', '------') print(' ', '| |') print(' ', '| O') print(' ', '| ') print(' ', '| ') print(' ', '| ') print('------------') if x == 2: print(' ', '------') print(' ', '| |') print(' ', '| O') print(' ', '| -|-') print(' ', '| ') print(' ', '| ') print('------------') if x == 3: print(' ', '------') print(' ', '| |') print(' ', '| O') print(' ', '| -|-') print(' ', '| | ') print(' ', '| ') print('------------') if x == 4: print(' ', '------') print(' ', '| |') print(' ', '| O') print(' ', '| -|-') print(' ', '| | ') print(' ', '| / \\') print('------------')#Hangmanfrom time import sleepimport randomfrom hangman_parts import parts#Prints a hangman pictureprint("Welcome to Hangman")print(' ', '------')print(' ', '| |')print(' ', '| O')print(' ', '| -|-')print(' ', '| |')print(' ', '| / \\')print('------------')print('Let me think of a word')#Wait time functiondef wait(): for i in range(5): print('.', end = "") sleep(.5) print() wait()#List of wordswords = ['mouse', 'cat', 'fish', 'robot', 'computer']picked = random.choice(words)print("Okay Ive got it!")print("The word has", len(picked), "letters")for i in range(len(picked)): print('_',' ', end = "") print()#Creates a list with _ marks for lettersright = ['_'] * len(picked) wrong = []#Prints letters in right with _'sdef add_letter(): for i in right: print(i, ' ', end = "") print()#Prints out wrong lettersdef wrong_letter(): print("Wrong letters:", end = "") for i in wrong: print(i,' ',end = "") print()#Main Loop while True: print('=====================') guess = input("Guess a letter") if guess in picked: print("Let me check") ###Handles letter that appear more than once index = 0 for i in picked: if i == guess: right[index] = guess index = index + 1 wait() add_letter() wrong_letter() parts(len(wrong)) elif guess not in picked: print("Let me check") wait() if guess in wrong: print("You already guessed", guess) wrong_letter() else: print(guess, "is not in my word") wrong.append(guess) add_letter() wrong_letter() parts(len(wrong)) if len(wrong) > 4: print("Game Over!") print("I picked", picked) break if '_' not in right: print("You guessed it!") print("I picked", picked) break cat
dog
robot
paper
file = open("words.txt", "r")words_list = file.read().split('\n')#Hangmanfrom time import sleepimport randomfrom hangman_parts import parts#Prints a hangman pictureprint("Welcome to Hangman")print(' ', '------')print(' ', '| |')print(' ', '| O')print(' ', '| -|-')print(' ', '| |')print(' ', '| / \\')print('------------')print('Let me think of a word')#Wait time functiondef wait(): for i in range(5): print('.', end = "") sleep(.5) print() wait()#List of wordsfile = open("words.txt", "r")words_list = file.read().split('\n')picked = random.choice(words_list)print("Okay Ive got it!")print("The word has", len(picked), "letters")for i in range(len(picked)): print('_',' ', end = "") print()#Creates a list with _ marks for lettersright = ['_'] * len(picked) wrong = []#Prints letters in right with _'sdef add_letter(): for i in right: print(i, ' ', end = "") print()#Prints out wrong lettersdef wrong_letter(): print("Wrong letters:", end = "") for i in wrong: print(i,' ',end = "") print()#Main Loop while True: print('=====================') guess = input("Guess a letter") if guess in picked: print("Let me check") ###Handles letter that appear more than once index = 0 for i in picked: if i == guess: right[index] = guess index = index + 1 wait() add_letter() wrong_letter() parts(len(wrong)) elif guess not in picked: print("Let me check") wait() if guess in wrong: print("You already guessed", guess) wrong_letter() else: print(guess, "is not in my word") wrong.append(guess) add_letter() wrong_letter() parts(len(wrong)) if len(wrong) > 4: print("Game Over!") print("I picked", picked) break if '_' not in right: print("You guessed it!") print("I picked", picked) break