Bummer: Didn't get `D20`s in my `Hand` instance
I'm not sure where I went wrong
import random class Die: def __init__(self, sides=2): if sides < 2: raise ValueError("Can't have fewer than two sides") self.sides = sides self.value = random.randint(1, sides) def __int__(self): return self.value def __add__(self, other): return int(self) + other def __radd__(self, other): return self + other class D20(Die): def __init__(self): super().__init__(sides = 20)
from dice import D20 class Hand(list): def __init__(self, *args, **kwargs): super().__init__() @classmethod def roll(cls, size): num =  for item in range(size): num.append(D20().value) return num @property def total(self): return sum(self)
Austin Loos7,046 Points
I believe the problem is that the autograder is looking for instances of D20, but instead of getting a class object, it's getting .value of the object. Try appending just D20() to num instead of D20().value
Mary Eke4,494 Points
Hello Amelia, thank you for requesting my help.
However, your coding and the problem with the coding looks super advanced. I am at the beginner's level of Python and I am also not learning the programming language anymore as I have decided to focus on something else for now. Therefore, I won't be able to provide the appropriate help to you. I am sorry that I couldn't be of help.
I hope that other people provide you with the help that you need.