Step 3: Keep Guessing ๐
One guess and the game ends? That's the shortest game ever. ๐ A real detective keeps working the case until they crack it.
A while loop repeats a block as long as something is true:
password = ""
while password != "banana":
password = input("Password? ")
print("You're in!")
Read it out loud: while the password is not banana, keep asking. The moment it matches, Python jumps past the loop.
Notice the loop asks again at the end โ that's what keeps it going. And now that the game is a real challenge, that spy print has to go. ๐
Your mission
- Delete the line that reveals the secret โ no peeking!
- Wrap the clue part in
while guess != secret: - Inside the loop: print the clue, then ask for a new guess
- After the loop, print the victory message
Your code
Press โถ Run to see what your code does!