code

 avatar
unknown
plain_text
a year ago
943 B
4
Indexable
import random

def game():
    print("Welcome to Hangman!")
    x = input("How many letters do you want the word to be?")
    wordlist = ["Bumfuzzle",  "Fartlek", "Everywhen", "Apple", "Monkeys"]
    char_counts = [len(word) for word in wordlist]
    position = ""
    word = ""
    #You found how many letters are in their word they want, and that's num
    for num in char_counts:
        if num == x:
            #You found position in the second list
            position = char_counts.index(num)
            word = wordlist[position]
            return word, num
        else:
            print("Choose a different length of words")
            game()
    if num == "7":
        print('_ _ _ _ _ _ _ ')
    elif num == "8":
        print('_ _ _ _ _ _ _ _')
    else:
        print('_ _ _ _ _ _ _ _ _')
    for char in wordlist:
        print(char, end=' ')
game()
print("Guess your letters!")
# theWord = word
Editor is loading...
Leave a Comment