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

KRIS NIKOLAISEN
KRIS NIKOLAISEN
53,478 Points

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