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

"No 'score_yatzy' method" error, even though it's right there.

For some reason it's telling me that the 'score_yatzy' method isn't there, even though its clearly stated:

def score_yatzy(self, hand):
        for count in hand.sets.values():
            if count == 5:
                return 50
            else:
                return 0
scoresheets.py
class YatzyScoresheet:
    def score_ones(self, hand):
        return sum(hand.ones)

    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)

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

    def score_yatzy(self, hand):
        for count in hand.sets.values():
            if count == 5:
                return 50
            else:
                return 0

1 Answer

Steven Parker
Steven Parker
231,269 Points

When method code has a syntax error, the typical challenge message just says there is no method. In this case, the error is from referencing "sets" instead of "_sets" (with an underscore).

You'll also need to rework your strategy a bit. You don't have to use a loop for this; but if you do, you'll probably not want the method to return during the first iteration.