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 trialStephen Lorenz
3,271 PointsWhat does the "or" do in self.value = value or random.rantint(1,sides)
In Kenneth's example, what does the "or" do there? it seems like it'd make a boolean comparison between value (in his examples is 0) and whatever random number got returned. Why not just have the random number generator return a value?
1 Answer
Eric Peppler
3,675 PointsIf value = 0, which it is initialized as, self.value will only be equal to random.rantint(1,sides). If, however, value is defined as nonzero then self.value = value, regardless of what random.rantint(1,sides) ends up being. Hope that helps.
Stephen Lorenz
3,271 PointsStephen Lorenz
3,271 Pointsoooh, ok, cool! Thank you!