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
marcusurso
417 PointsWhy do you have to declare a function False before writing an if statement?
I'm asking this question dislocated from an actual problem/quiz. I seem to recall that I needed to declare the function False prior to writing the if statement to define the True value of the function. I'm curious, why do you have to do this in order for the function to run?
1 Answer
Steven Parker
243,656 PointsDo you mean "declare the function's return value False"? You don't need to do that, but it is a common design pattern. Another equally viable pattern is to use an "else" statement to handle returning False when the test condition is not true.