Step 4: Count the Tries ๐ข
Your game runs until the case is cracked. But cracking it in 3 guesses should feel way better than cracking it in 30 โ and right now the game can't tell the difference. ๐คจ
That's a job for a counter: a variable that starts at zero and grows:
cookies = 0
cookies = cookies + 1 # now it's 1
cookies = cookies + 1 # now it's 2
The trick is where you put the counting line. Every single place a guess happens, the counter has to tick up right after it.
Your mission
- Before the guessing starts, make
tries = 0 - Add 1 to
triesafter every guess โ including the one inside the loop - Make the victory message brag about the count, like
You cracked it in 6 tries!
Your code
Press โถ Run to see what your code does!