Question: Language: Python 3.6.1 ____________________________________________________________________ secret_word = 'apple' incorrect_guesses_left = 10 guessedCorrectly = False # Printing the length of secret word print(The secret word has length

Language: Python 3.6.1

____________________________________________________________________

Language: Python 3.6.1 ____________________________________________________________________ secret_word = 'apple' incorrect_guesses_left = 10 guessedCorrectly =

secret_word = 'apple'

incorrect_guesses_left = 10

guessedCorrectly = False

# Printing the length of secret word

print("The secret word has length " + str(len(secret_word)) + ".")

# Loop till user made a correct guess or number of tries exceeded

while incorrect_guesses_left > 0:

# Printing number of guesses left

print("You have " + str(incorrect_guesses_left) + " incorrect guesses left.")

# Taking user guess

guess = input("Guess: ")

# Checking for length of guess

if len(guess) != len(secret_word) and len(guess) != 1:

print("This is not a valid guess.")

elif len(guess) == 1:

# Checking character

if guess not in secret_word:

print("That letter is not in the word.")

incorrect_guesses_left = incorrect_guesses_left - 1

else:

# Counting number of occurrences

cnt = 0

# Iterating over secret_word

for ch in secret_word:

# Comparing character by character

if ch == guess:

# Updating count

cnt += 1

# Printing number of occurrences

print("That letter is in the word! Count: " + str(cnt))

# Checking for length of guess

elif len(guess) == len(secret_word) and guess != secret_word:

print("That is not the correct word.")

incorrect_guesses_left = incorrect_guesses_left - 1

elif guess == secret_word:

print("That is the correct word!")

guessedCorrectly = True

break

# Printing error message

if guessedCorrectly == False:

print("You are out of incorrect guesses... Secret Word: " + secret_word);

________________________________________________________________________

The above program is what i did.

False # Printing the length of secret word print("The secret word has

length " + str(len(secret_word)) + ".") # Loop till user made a

i dont know how to modified the progam in order to show the correct answer.

mainpy saved 1 ecret word- 'apple 2 incorrect guesses left 10 4 guessedCorrectly - False 6 # Printing the length of secret word 7 print("The secret word has length " + str(len(secret_word)) + ".") 9 # Loop till user made a correct guess or number of tries exceeded 10 while incorrect guesses left > e: 12 | | # Printing number of guesses left print ("You have" str(incorrect guesses left) " incorrect guesses left. ") 14 15 | | # Taking user guess 16 17 18 | | # Checking for length of guess 19 | | if len(guess) !-len(secret word) and len(guess) != 1: 20 print("This is not a valid guess.") 21 | | elif len(guess)-1: guess# input("Guess: ") # Checking character if guess not in secret word: print("That letter is not in the word.") 25 26 incorrect_guesses left incorrect guesses left 1 else: # Counting number of occurrences 28 cnt e # iterating over secret wo 30 31 32 for ch in secret_word: # Comparing character by character if ch guess: # Updating count ent+1 35 # Printing number of occurrences 36 print(" That letter is in the word! Count: "str(ent)) 37 | | # Checking for length of guess 38 elif len(guess)len(secret word) and guess le secret word: 39 print("That is not the correct word.") incorrect_guesses left incorrect guesses_left 1 41 elif guess secret words 42 print("That is the correct word!") 43 guessedCorrectly True break 45 46 # Printing error message 47 if guessedcorrectlyFalse 48 print("You are out of incorrect guesses... Insecret Word: secret word)s

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!