Skip to content

Instantly share code, notes, and snippets.

@codewithkevin
Last active April 5, 2022 17:33
Show Gist options
  • Save codewithkevin/d633e5a42c5fc1e509443965c902f1cf to your computer and use it in GitHub Desktop.
Save codewithkevin/d633e5a42c5fc1e509443965c902f1cf to your computer and use it in GitHub Desktop.
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