CodeAgeBy Sitezack
Python for Builders — Level 4Functions and lists0 XP
Chapter progress0/6

Lesson 7 of 7

Project: Hangman

In hangman, the secret word is shown with _ for letters not found yet, and every wrong letter costs a life.

Your program will build the display letter by letter with a loop, then count the remaining lives.

display = ""
for letter in "ab":
    display = display + "_"

🎯 Your mission

The secret word is secret = "python" and the player guessed tries = ["a", "p", "o", "t"] with lives = 5. 1) Build display: for each letter of secret, add the letter if it's in tries, otherwise add "_". 2) For each guess in tries that is not in secret, subtract 1 from lives. 3) Print display then lives.

PRO lesson

This advanced chapter is part of CodeAge PRO. Unlock it to keep your adventure going.

Discover PRO