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 trialAndras Andras
8,230 Pointssneaky and light_level
Hello,
Can you help me understand why in "return self.sneaky and light_level" the self.sneaky does not appear but light_level is printed.
import random
class Thief: sneaky = True def pickpocket(self): if self.sneaky: return bool (random.randint(0,1)) #return False def hide(self, light_level): return self.sneaky and light_level
1 Answer
Henrik Christensen
Python Web Development Techdegree Student 38,322 Pointsreturn self.sneaky and light_level - this just mean that the method will return True if both self.sneaky AND light_level are True or 'truthy'.
If one of them is False or 'falsy' then the method will return False
Andras Andras
8,230 PointsAndras Andras
8,230 PointsThank you, Henrik.