Question
For this question you will create a version of the popular game mastermind! Go here to play an online version of the game: Mastermind online
For this question you will create a version of the popular game mastermind! Go here to play an online version of the game: Mastermind online (Note, your game will look and behave a bit differently).
The rules for your game are as follows:
The computer generates a password of 5 random integers between [1-5]. (e.g.: [3,1,4,4,2])
The user then has 10 turns to guess the password.
Each turn the user makes one guess, and the computer reports how many digits were correct.
Note: a correct guess is the right number in the right location.
Note: be careful with datatypes!
If the user guesses all five digits correctly, the game ends with a win message.
If the user runs out of turns, the game ends with a lose message.
You may assume that the user correctly enters 5 numbers, however you must allow them to enter all 5 into a single prompt (separated by spaces). (Tip: the string.split() method might be useful here.)
E.g.:
I've set my password, enter 5 digits in the range [1-5] (e.g. 1 3 2 4 4): 10 guesses remaining > 1 2 3 4 5 1 of 5 correct 9 guesses remaining > 2 3 4 5 1 0 of 5 correct 8 guesses remaining > 2 2 3 4 5 1 of 5 correct 7 guesses remaining > 3 3 3 4 5 1 of 5 correct 6 guesses remaining > 4 4 4 4 5 2 of 5 correct 5 guesses remaining > 5 5 4 5 5 1 of 5 correct 4 guesses remaining > 3 2 1 4 5 2 of 5 correct 3 guesses remaining > 1 1 1 4 5 3 of 5 correct 2 guesses remaining > 2 1 1 4 5 3 of 5 correct 1 guesses remaining > 3 1 3 4 5 2 of 5 correct 0 guesses remaining > 3 1 1 4 5 3 of 5 correct You'll never get my treasure because the password was ['4', '1', '1', '2', '5']
I need help with those code in python pls!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started