Extended Task 6

'Guess the Word' Game

Create a Python program similar to the hit New York Times puzzle game Wordle. Allow the user to make guesses to match the randomly chosen hidden word, stopping when they get it correct.

 

You can download a list of 5-letter words on this page. You will need to read in each line of the list and randomly select one - don’t forget to import the random library.

Check if each letter of the user’s inputted word is in the randomly selected word.

 

If you are using an IDE like Replit you can use the colorama library and the Fore command to turn the text:

  • Green if the letter is in the correct position.

  • Red if the letter is not in the selected word.

  • Yellow if the letter is in the selected word but not in the correct position.

Add your own flair and additional features to your program as an extension, including limiting the number of guesses and recording how many attempts it took to get the correct answer.

Download a file of 534 5-letter words:

For this task, you will need to create a document and include the following sections (with screenshots where appropriate):

  • An introduction to explain the Purpose of your program.

  • List of Requirements for a successful program.

  • Screenshots of your code (with comments in your code to show understanding).

  • Testing – Create a plan to show how you will test your program and then explanations of any errors that you found and how they were fixed.

  • An Evaluation of what worked, what didn’t, and how you met each of your requirements from your original list. Also, discuss further improvements that you could have made to improve your program.

Reminders for this task:

  • You will need a while loop to repeatedly allows the user to enter words until they match the correct word.
     

  • Section 10 will help you to open, write and read from files. Download the file of 5-letter words from the link above.
     

  • You will need to randomly select a word from the file. The choice command will help.
     

  • Selection will be necessary to check if each letter in the inputted word matches the letter in the same position in the correct word. String handling is needed to select specific letters in a string.
     

  • You will need to use .rstrip() on the selected line (word) that you have randomly chosen from the file. This removes any hidden characters that may interfere with checking if it is equal to the inputted word.
     

  • There are multiple ways to approach this program, and your solution might look different from the example. Break the problem down and focus on one part at a time.

Example solution:

The word the user enters should be checked, letter by letter, against the letters in the same position in the randomly chosen correct word.

Remember that the first letter in a word has the position 0, not 1.

Below is an example of some incomplete code you may wish to use in your solution.

word1.png
word2.png
word3.png