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

Kursinhalt

Crafting a Classic Hangman Game

book
Guessed Word

Preventing Excessive Gameplay

The program must recognize when to cease prompting the user for letters once the word has been successfully guessed. To achieve this, we'll develop the is_word_guessed function. This function will effectively communicate:

Great, the player has guessed the word correctly! It's time to halt the program and congratulate the player.

Aufgabe

Swipe to start coding

  1. Define the is_word_guessed function with gameword and letters_already_guessed as parameters.
  2. Implement a condition to verify whether letters_already_guessed matches gameword.
  3. Return True if the condition is met, and False otherwise.

Lösung

Note

During the execution of the second step, employ the set(gameword) & set(letters_already_guessed) expression to compare it with the set(gameword). This approach ensures that only the letters from letters_already_guessed that are in gameword are considered. The & operator identifies letters common to both sets.

Mark tasks as Completed
Switch to desktopWechseln Sie zum Desktop, um in der realen Welt zu übenFahren Sie dort fort, wo Sie sind, indem Sie eine der folgenden Optionen verwenden
War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 1. Kapitel 3
AVAILABLE TO ULTIMATE ONLY
We're sorry to hear that something went wrong. What happened?
some-alt