Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
why does the counter += 1 go at the end of the entire in if block
it definitely feels like that at times, but i guess that is part of the process. Thanks Ryan! really appreciate the help
Andrew Uzoka The counter += 1 is actually in the "while" loop and not inside of the "if" conditional. (Indentation is an important key to understand in python programming). The reason it is there is because the code is counting every time a user attempts to guess the password. So while the password != 'opensesame' in other words if the password the user typed doesn't match then it updates the counter by 1 for every time a user makes an attempt to guess it. This way once they make 3 attempts, any additional attempt will exit the program and give them a message stating "Too many invalid password attempts". I hope this helps, if you need any clarification let me know.
yeah that makes sense assume i wanted to make the password to only have int values, would i use a if statement to check against if it is a string the raise a value error e.g if passoword != str: raise valueError("This is not an int")
just trying to attempt a few things
okay thanks. is it natural to have these difficulties when your starting out? as you immerse yourself do you start to understand and does it get easier over time ?