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 trialJacob Brookhart
Courses Plus Student 6,765 Pointspres = pres or set()
So another newbie question... in this code challenge, the function is already populated with pres = pres or set. The default condition of pres = None. So why is it that this code selects an empty set (set()) instead of an empty variable? How is this hierarchy organized?
1 Answer
Steven Parker
231,248 PointsThe value "None" is considered "falsey". So when "pres" is "None", then the code "pres = pres or set()
" works the same as if it were just "pres = set()
".
Jacob Brookhart
Courses Plus Student 6,765 PointsJacob Brookhart
Courses Plus Student 6,765 PointsAny recommendation on where to find the documentation for this? It makes sense but I think I need to go into the semantics of it
Steven Parker
231,248 PointsSteven Parker
231,248 PointsYou might look in the official Python documentation on Truth Value Testing and Boolean Operations.
Jacob Brookhart
Courses Plus Student 6,765 PointsJacob Brookhart
Courses Plus Student 6,765 PointsThank you!