Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python Dice Roller Giving a Hand

TypeError

When I try to create an instance of the Hand class in the python shell I get the following error message:

>>> import dice, hands                                                                                                                                 
>>> hand = hands.Hand(size=5, die_class=dice.D6)                                                                                                       
Traceback (most recent call last):                                                                                                                     
  File "<stdin>", line 1, in <module>                                                                                                                  
TypeError: list() takes at most 1 argument (2 given)                                                                                                   

Here is my code (as far as I can see it matches the code in the lesson):

class Hand(list):
  def __int__(self, size, die_class=None, *args, **kwargs):
    if not die_class:
      raise ValueError("You must provide a die class")
    super().__init__()

    for num in range(size):
      self.append(die_class())

1 Answer

You have int instead of init here:

def __int__(self, size, die_class=None, *args, **kwargs):

should be

def __init__(self, size, die_class=None, *args, **kwargs):

Thanks