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 trial
Sam Fellows
3,968 Points"if not" presumes I know in advance the answer to my question is going to be false. What if I don't have the answer?
"if not" presumes I know in advance the answer to my question is going to be false. What if I don't have the answer in advance? Perhaps this will be answered later, but what if I have a problem I need to solve where I am evaluating something for which I can't know the answer in advance. I played around in terminal and found that Python won't spit out anything if indeed something in false.
1 Answer
Ken Alger
Treehouse TeacherSam;
As an example of when if not might come in handy would be for something like password checking. If the input is not equal to some value (preferably hashed in a password situation), then return the user to the login stage of the app. Otherwise let them pass on through.
Provide an example of the situation you are thinking of and we can look at it.
Happy coding,
Ken
Sam Fellows
3,968 PointsSam Fellows
3,968 PointsThanks Ken! Makes sense. I believe I was overthinking it.