Amir Shahabnia27,270 Points
Get AttributeError while trying to get hand.value
I am trying to get the value from an instance of the Hand class but I get an
AttributeError when I try hand.value assigned with die_class=D6.
Everything seems to be working but not the value of each of dices. Please help :))
Here is my code for the class:
class Hand(list): def __init__(self, size=0, die_class=None, *args, **kwargs): if not die_class: raise ValueError("You must provide a die class") super().__init__() for _ in range(size): self.append(die_class)
Below is my code implemented on terminal including the Attribute Error:
>>> from dice import D6 >>> from hands import Hand >>> hand = Hand(size=5, die_class=D6) >>> hand <class 'dice.D6'> >>> hand.value Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: type object 'D6' has no attribute 'value'
Nehemie Balukidi405 Points
Hi there, the error says that a D6 object does not have an attribute named value. Can you try to do something like: dir(D6) or dir(hand) to see the attributes of a D6 object, post the output back if you still can't find a way forward? so we can try to help