The classic game of Mastermind is played on a tray on which the Mastermind conceals a code and the Guesser has 10 tries to guess it. The code is a sequence of 4 (or 6, sometimes more) pegs of different colors. Each guess is a corresponding sequence of 4 (or more) pegs of different colors. A guess is "correct" when the color of every peg in the guess exactly matches the corresponding peg in the Mastermind's code.
After each guess by the Guesser, the Mastermind will give a score comprising black & white pegs, not arranged in any order:
guess peg matches the color of a code peg in the same position.guess peg matches the color of a code peg in another position.Create a function that takes two strings, code and guess as arguments, and returns the score in a dictionary.
code and guess are strings of numeric digitsguess_score("1423", "5678") ➞ {"black": 0, "white": 0}
guess_score("1423", "2222") ➞ {"black": 1, "white": 0}
guess_score("1423", "1234") ➞ {"black": 1, "white": 3}
guess_score("1423", "2211") ➞ {"black": 0, "white": 2}
code and guess sequences will have the same length.