Python Object-Oriented Python Dice Roller Chance Scoring

Pro Student 1,784 Points

need help with 'chance scoring'

Error says: Wrong value for non-yatzy. I am not usre if I understand the question correctly after seeing the error.
class YatzyScoresheet:
    def score_ones(self, hand):
        return sum(hand.ones)

    def score_chance(self, hand):
        return sum(hand)

    def score_yatzy(self, hand):
        if len(hand) == 5:
            for die in hand:
                dievalue = int(die)
                if sum(hand) == (dievalue * 5):
                    return 50
        return 0

    def _score_set(self, hand, set_size):
        scores = [0]
        for worth, count in hand._sets.items():
            if count == set_size:
        return max(scores)

    def score_one_pair(self, hand):
        return self._score_set(hand, 2)

2 Answers

Jordan Hoover
Jordan Hoover
Python Web Development Techdegree Student 38,750 Points

Your conditional check at the end is always going to be True, its not necessarily checking if all elements have the same value.

I would take a look at this list comprehension technique, its good to know about.

Pro Student 1,784 Points

It worked, thanks for helping !!