Question
Python Program - Secret word game! The program contains a hidden secret word stored in a variable. This word can have any number of letters
Python Program - Secret word game!
The program contains a hidden secret word stored in a variable. This word can have any number of letters in it. When the program runs, the user is shown underscores ( _ ) for each letter of the word.
The user then enters a guess. If the guess is correct, the user wins and the game is over.
If the guess is not correct, the user will be given a hint to help them improve their guess for the next round.
The game continues prompting the user for new guesses and showing them hints until they guess the word correctly. When the game is over, the program displays the number of guesses that were made.
The guess must be the same number of letters as the secret word. If the guess has a different number of letters, the user is given a message explaining this, and no hint is provided.
The hint is a rendering of the letters in the guess according to the following guidelines:
An underscore _ indicates that the letter was not present in the secret word.
A lowercase letter indicates that the letter was present somewhere in the secret word, but not at that position.
An uppercase letter indicates that the letter was present at that exact spot in the secret word. (In other words, if the second letter in the guess is also the second letter in the secret word, then that letter is shown as capital.)
Because capital letters have meaning in our hints, the secret word should be all lowercase. Similarly, when the user enters their guess, convert it to lowercase prior to checking for matches.
If the guess has a different number of letters than the secret word, it still counts as a guess, but the user does not receive a hint.
The steps should be:
Have a secret word stored in the program.
Prompt the user for a guess.
Continue looping as long as that guess is not correct.
Calculate the number of guesses and display it at the end.
It does not need to have any hints at this point.
Add the hints according to the previously stated rules
Add a check to verify that the length of the guess is the same as the length of the secret word. If it is not, display a message. If they are the same, then proceed to give the hint.
Use a loop to generate the initial hint.
Make sure to account for the following in the hints:
Letters that are not present at all in the secret word (underscore _).
Letters that are present in the secret word, but in a different spot (lowercase).
Letters that are present in the secret word at that exact spot (uppercase).
The game begins with with this list of words: Book, Big Data, Cloud, AI, IoT, Predictive Analytics, Cyber Security, Phishing
Select a random one for the secret word.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started