Question: 9 . Define the displayCorrectDigits ( secretCode , userGuess, numDigits ) function. Parameter 1 : secretCode is a list containing integers with the secret code

9. Define the displayCorrectDigits(secretCode, userGuess, numDigits) function. Parameter 1: secretCode is a list containing integers with the secret code that the user is trying to crack Parameter 2: userGuess is a list containing integers with the users guess of the secret code Parameter 3: numDigits is an integer that is the number of digits in each list (the lists are the same length) Return value: None This function displays messages about each digit in the userGuess list. o Print the following message: Let's see if you have any correct digits o You want to see whether the user guessed a digit in the code list. Use a for loop with the range() function depending on the numDigits parameter. This for loop allows you to get the index of each digit in the lists. o Inside the for loop, create a variable to hold the digit in the userGuess list at the index (i.e., variable created by for loop). Create a second variable to hold the digit in the secreteCode list at the index. Create a third variable to hold the number of times the digit in the userGuess list occurs in the secretCode list by calling the list.count() method.

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 Programming Questions!