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 trialJames Estrada
Full Stack JavaScript Techdegree Student 25,866 PointsWhy are we returning None at the end of the function?
Doesn't Python return None by default if no return statement was given?
1 Answer
Moosa Bonomali
6,297 PointsIt is true that If the function does not return a, then if you read that function into a variable, you will get a None if the function did not return a value. However when taking into account the PEP8 Standard, which provides styling guidelines to make code more readable and more understandable, then according to the PEP8 standard;
Be consistent in return statements. Either all return statements in a function should return an expression, or none of them should. If any return statement returns an expression, any return statements where no value is returned should explicitly state this as return None, and an explicit return statement should be present at the end of the function (if reachable).