You've watched plenty of tutorials build a guessing game. Now build the core logic yourself — no copying, just you and the editor.
A player is trying to guess a secret number. Instead of using random input, the guesses are already given to you in a list so your program's output is predictable and easy to check. Your job is to loop through the guesses, tell the player whether each guess is too high, too low, or correct, and stop as soon as they get it right.
Your tasks
Given these starting values:
secret = 42
guesses = [50, 30, 42]
attempts = 0
1. Loop over each guess in guesses.
2. Inside the loop, add 1 to attempts for every guess.
3. Use if / elif / else to print feedback: if the guess equals secret, print "{guess}: Correct!" and break; if it's less than secret, print "{guess}: Too low"; otherwise print "{guess}: Too high".
4. After the loop, print "Solved in {attempts} attempts".
Expected output
50: Too high
30: Too low
42: Correct!
Solved in 3 attempts
Constraints
- Use a
for loop over guesses
- Use
if / elif / else for the comparison
- Use
break to stop once the guess is correct
- No external libraries; no
random