Lazo Lab Sign up

Python Projects & Skills / Games

Lesson 8 of 28

Hangman

Show underscores for unguessed letters and track wrong guesses. Sets make it easy to check which letters are left.

Key points

  • Store guessed letters in a set
  • Build the display with a comprehension
  • Limit wrong guesses
shown = " ".join(c if c in guessed else "_" for c in word)
Watch a video on thisOpens YouTube search results for “Hangman” in a new tab

Quiz · +10 XP

Which data type is best for storing guessed letters?

Log in to save progress and earn XP.