Step 5 – add the guesses in
Here's an improved version of the Scratch program which counts the number of guesses the player takes.
It has three things to add in.
We can do this in Python as well, using pretty much the same code.
- The first line to add needs to set guesses to 0
- Then straight after a guess use a line that goes guesses = guesses + 1 to add a guess
- The last line to add is a little more complex. Use the screenshot below to add that.
That's this puzzle done. Can you code a linear search as well?