day 7 - didn't like it

This commit is contained in:
2025-06-15 00:10:07 +02:00
parent b77a308a84
commit 8c0b19bb6c
2 changed files with 56 additions and 15 deletions

41
007/task.py Normal file
View File

@ -0,0 +1,41 @@
import random
word_list = ["aardvark", "baboon", "camel"]
chosen_word = random.choice(word_list)
print(chosen_word)
placeholder = "_" * len(chosen_word)
print(placeholder)
found_letters = []
lives = 6
display = placeholder
while "_" in display and lives > 0:
guess = input("Select a letter:\n").lower()
display = ""
found_a_letter = False
for letter in chosen_word:
if letter == guess:
display += letter
found_a_letter = True
found_letters.append(letter)
elif letter in found_letters:
display += letter
else:
display += "_"
if found_a_letter == False:
lives -= 1
print(display)
if lives == 0:
print("Game over!")
else:
print("You won!")