๐Ÿ PyQuest๐Ÿ•ต๏ธ Game: Number Detective ยท ๐Ÿ”ข Step 4: Count the Tries
โญ 0 XP๐Ÿ Python is waking upโ€ฆ

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

  1. Before the guessing starts, make tries = 0
  2. Add 1 to tries after every guess โ€” including the one inside the loop
  3. 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!