Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
The secret number is . The game gives at most guesses. What does it show if the player types , and ?
Join two conditions with and in the while line.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Plan. The loop continues while the guess is wrong and tries < 5.
Too high.Too low.Correct in 3 tries.If the player had not found it in 5 guesses, the loop would end anyway, and the game would say Out of guesses.
Log in to join the discussion.
Loading…