Step 2: One Guess, One Clue ๐
The computer has a secret. Now let a detective take a shot at it. ๐ต๏ธ
There's one catch: input() always hands back text, and you can't
compare text to a number. Wrap it in int() and it becomes a real number:
age = int(input("How old are you? "))
if age >= 13:
print("Teenager!")
Once it's a number you can use < and > to give clues.
Your mission
- Keep the secret and keep the spy print (you'll delete it next step)
- Ask for a guess with
guess = int(input("Guess my number (1-50): ")) - Use
if/elif/elseto print one of three clues:- guess is smaller than the secret โ "Too low!"
- guess is bigger โ "Too high!"
- otherwise โ they nailed it! ๐
Your code
Press โถ Run to see what your code does!