Question: Set a secret word in your code and store this in a variable. DON T ask the user to set this secret word. You must
Set a secret word in your code and store this in a variable. DONT ask the user to set this
secret word. You must set this yourself in the code. Ex: secretword TOAST
Have the game be in a loop. The game will keep asking the user for a word until they
successfully guess the secret word.
Inside the loop:
a Display the message Guess the word! followed by how many letters the word
has. Ex: Guess the word! Word length:
b Keep track of how many guesses the user has made so far using a counter. As a
hint to the user, reveal to them some of the letters from the secret word. The
number of letters to reveal should be equal to the number of guesses they have
made. For example, if theyve made guesses, reveal letters.
c Display all the guesses the user has made so far. You will need an array to keep
track of all the guesses the user has made. DONT just print the array itself like:
printmyarray You will need to iterate through the array and print each
element.
d Prompt the user for their guess. This guess does not have to be casesensitive So
if your word is TOAST and they enter toast or Toast, either guess would be
correct.
e If the user enters the correct guess, stop the loop and then display the message
Correct followed by the secret word.
f If the user does not enter the correct guess, add this incorrect guess to the list of
guesses theyve made so far, and also add to the counter that tracks how many
guesses theyve made. Keep the loop going.
g If the number of guesses becomes equal to the length of your secret word, that
means the user was not able to guess the secret word. Stop the loop and display
the message Game over! followed by the secret word.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
