Gallery
Intro to Python
Share
Explore

icon picker
Guess the Word

In this section, you’ll be programming your own “guess the word” game.
We’ve broken down the project into four parts.
Task
Section
Status
1
🎲 Handle user input
Guess the Word
Not Started
2
🎲 Keep track of guesses
Guess the Word
Not Started
3
🎲 Show the word progress
Guess the Word
Not Started
4
🎲 End the game
Guess the Word
Not Started
5
🍦 Add bonus features to your game
Guess the Word
Not Started
No results from filter

Setup

Go to and click on the “Fork” button at the top. This will create your own copy of the code.
Optional: The starter code has a file called codebank.txt. If you don’t feel comfortable writing your own code from scratch, you can copy the code snippets for each part. You will need to find the right place to use each piece of code, and you’ll need to add your own indentation.

Part 1: Handle user input

Your first task is to have the user guess a letter and let them know if the letter is in your word. To start, we'll let the user guess an infinite number of times.

Example

Assume the word to guess is “collaborative”.
The red text represents user input (as opposed to program output).

Part 2: Keep track of guesses

Your next task is to keep track of how many letters the user has guessed and how many guesses they have remaining.
If the player guesses a letter they have already guessed, do not count it as another guess.

Example

Assume the word to guess is “collaborative”.
The red text represents user input (as opposed to program output).

Part 3: Show the word progress

Your next task is to reveal the location of the guessed letters in the word.
Write a function get_word_progress that takes as input the word to guess and a set of letters that have been guessed. It should return a string that represents the word to guess with unguessed letters replaced by the * character.
Example:

Example (game play)

Assume the word to guess is “collaborative”.
The red text represents user input (as opposed to program output).

Part 4: End the game

The last task is to end the game when the player has either guessed the word or reached the guess limit.
Write a function is_word_guessed that takes as input the word to guess and a set of letters that have been guessed. It should return True if all the letters in the word have been guessed and False otherwise.
Example:

Example (winning game)

Assume the word to guess is “dog”.
The red text represents user input (as opposed to program output).

Example (losing game)

Assume the word to guess is “dog”.
The red text represents user input (as opposed to program output).

Extensions

If you finish early and are looking for ways to extend your game, here are some ideas:
Create a random list of words and select a random word to guess each time (Hint: the may be helpful).
Verify the player’s guess and print an error message if they guess something that’s not a letter in the alphabet.
Let the user guess an entire word.
Your own idea

If you used the codebank for your solution, try redoing this challenge by writing your own code from scratch!

Solution

View the .


Share
 
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.