Answer:
#Python Program to solve the above illustration
# Comments are used for explanatory purpose
# define a function named game that take two parameters, player1 and player2
def Game(player1, player2):
# Record score
Score = [0, 0]
# Count trials
Trials = []
# Compare player1 guess with player2 hidden items
for i in range(len(player2)):
if player2[i]==player1[i]:
Trials.append(i)
#The above is done if player1 guessed correctly
#increase score by 1 below
Score[0] += 1
# Calculate trials and scores
for i in range(len(player2)):
for j in range(len(player2)):
if (not(j in Trials or i in Trials)) and player2[i]==player1[j]:
Score[1] += 1
Trials.append(j)
# Output scores
return Score
#Test program below
In []: player1 = ['yellow','yellow','yellow','blue','red']
In []: player2 = ['yellow','yellow','red','red','green']
In []: Game(player1, player2)