Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJakub Jeczalik
5,379 PointsRunning on python 3.6
When running the code in the video, after entering the password 3 times, I do not receive the message "Too many password attempts
1 Answer
Dylan Bailey
574 PointsHey Jakub! Not sure what's going on with your code, since I can't see it.
If you're not receiving that message, then there's a good chance something is going on with your attempt_count variable.
import sys
MASTER_PASSWORD = "opensesame"
password = input("Please enter the super secret password: ")
attempt_count = 1
while password != MASTER_PASSWORD:
if attempt_count > 3:
sys.exit("Too many invalid password attempts!")
password = input("Invalid password, try again: ")
attempt_count += 1
print("Welcome to secret town")
Make sure you're nesting your if statement inside of the while loop. And make sure you're incrementing your attempt_count variable at the end of your while loop.