Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
State of Affairs | Crafting a Classic Hangman Game
Crafting a Classic Hangman Game
course content

Course Content

Crafting a Classic Hangman Game

bookState of Affairs

Tracking the Game Word's Progress

To keep the user informed about the progress of their guesses, it's essential to display both the number of correctly guessed letters and the letters still to be guessed after each attempt.

For this purpose, we will develop the get_guessed_word function. This function will maintain a result_list, which represents the current state of the gameword, including correctly guessed letters and placeholders for the remaining letters.

Task
test

Swipe to show code editor

  1. Define the get_guessed_word function with gameword and letters_already_guessed as parameters.
  2. Create a for loop to iterate through gameword using i as the iterator, utilizing the range() function for iteration.
  3. Implement a condition to determine if elements within gameword match any in letters_already_guessed.
  4. If the condition is met, append the letter list(gameword)[i] to result_list; otherwise, append '_ ' (including the space).

Mark tasks as Completed
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Tracking the Game Word's Progress

To keep the user informed about the progress of their guesses, it's essential to display both the number of correctly guessed letters and the letters still to be guessed after each attempt.

For this purpose, we will develop the get_guessed_word function. This function will maintain a result_list, which represents the current state of the gameword, including correctly guessed letters and placeholders for the remaining letters.

Task
test

Swipe to show code editor

  1. Define the get_guessed_word function with gameword and letters_already_guessed as parameters.
  2. Create a for loop to iterate through gameword using i as the iterator, utilizing the range() function for iteration.
  3. Implement a condition to determine if elements within gameword match any in letters_already_guessed.
  4. If the condition is met, append the letter list(gameword)[i] to result_list; otherwise, append '_ ' (including the space).

Mark tasks as Completed
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 4
AVAILABLE TO ULTIMATE ONLY
We're sorry to hear that something went wrong. What happened?
some-alt