Hint
🧠Not sure how to start?
Try breaking the game down into steps:
Store the secret word in a variable, e.g.
"python"
.Create an empty list to keep track of guessed letters, like:
guessed_letters = []
Use a
while
loop to keep the game running until the user either guesses the word or runs out of tries.Inside the loop:
Build a string showing the current progress:
display_word = ""
for letter in secret_word:
if letter in guessed_letters:
display_word += letter
else:
display_word += "_"
Print it out so the user can see what they've guessed so far.
Ask the user for a letter with
input()
and check if it’s in the word.Keep a
tries
counter. If the guess is wrong, reduce it by 1.
Keep going until the user either completes the word or runs out of tries!
Click Show Solution if you’d like to see how all of this fits together.