Mission: Secret Clubhouse Password ๐
You are the bouncer at the door of a very exclusive clubhouse. Nobody gets in without the password โ and nobody gets in if they're too young, either.
Time to combine everything from Unit 2 with input() from Unit 1.
One new trick you'll need: input() always hands you back text,
even when someone types a number. To compare it like a number, wrap it in
int():
age = int(input("How old are you? "))
if age >= 10:
print("Old enough!")
Without int(), Python would be comparing the word "11" to the number
10 and get very confused. ๐
Your mission
- Use
input()to ask for the secret password and store it in a variable - Use
input()again for their age โ wrapped inint()so it's a number - If the password is correct and they're at least 10 โ let them in! ๐
- Use
eliffor the sneaky case: right password, but too young โ something funny - Use
elseto send the wrong-password people away with a silly excuse
Make the messages as ridiculous as you want. That's the fun part.
Your code
Press โถ Run to see what your code does!