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 trialBegana Choi
Courses Plus Student 13,126 Pointswhy do we need value=0 argument in D6 class?
class D6(Die):
def __init__(self):
super().__init__(sides=6, value=0)
it seems ok to run. can you help me to understand?
1 Answer
Megan Amendola
Treehouse Teacherclass D6(Die):
def __init__(self, value=0):
super().__init__(sides=6, value=value)
The code in the video shows the value is set to a default of zero in the init so you have the option of passing in a value for a D6 dice. Ex: d6 = D6(3)
That value is then passed into the parent class to set the value. You're right, it's not needed for D6 to work. It is just giving the user the option of still being able to pass in their own value.