Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

srav
PLUS
srav
Courses Plus Student 3,476 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.

scoresheets.py
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:
                scores.append(worth*set_size)
        return max(scores)

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

2 Answers

Jordan Hoover
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jordan Hoover
Python Web Development Techdegree Graduate 59,268 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.