CHRISTOPHER HECKER1,865 Points
Suggestions to improve RPG roller 2/2
I found this challenge in need of some improvement. The description should say explicitly how the class is going to be called. I spent some time looking for the code hand.roll() as the description says "I'm going to use code similar to Hand.roll(2)". Why not just say, "I'll call the code with the following line: my_hand = Hand.roll(2)"?
Since challenges build on the lessons and previous challenges, the Hand class code should be consistent with that previously developed. I found the simplest solution to be
@classmethod def roll(cls, num_dice = 2): return cls(num_dice, die_class=D20)
while maintaining the rest of the class code (and importing D20 of course). But this solution fails, barking about not being able to take the length of the hand or something. On my local machine, the instance type is Hand and len() returns the length, no problem. Searching other discussions, I see that commenting out the self.sort() in the init allows the code checker to pass. I can't see any reason why the checker would fail on length simply since the instance is sorted.