Last active
April 5, 2022 17:33
-
-
Save codewithkevin/d633e5a42c5fc1e509443965c902f1cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
word_list = ["music","art","science", | |
"history","math","computer","programming", | |
"science","art","music","history","math", | |
"computer","programming"] | |
generated_word = random.choice(word_list) | |
print(generated_word) | |
display = [] | |
word_length = len(generated_word) | |
for _ in range(word_length): | |
display.append("_") | |
print(display) | |
end_game = False | |
def game(end): | |
while not end: | |
guess = input("Guess a letter: ").lower() | |
for poistion in range(len(generated_word)): | |
letter = generated_word[poistion] | |
if letter == guess: | |
display[poistion] = guess | |
print(display) | |
if "_" not in display: | |
print("You win!") | |
end_game = True | |
game(end_game) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment