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 Object-Oriented Python (retired) Inheritance Score Method

Ulises Zamora
Ulises Zamora
10,589 Points

For some reason the code challenge does not recognize my function "score", but the workspace does.

The challenge is not recognize my score function. When I open the challenge the default code in the challenge was not properly indented. I tried both, with 4 space indentation and 2 space indentation (default in this particular challenge). In workspace the same code give me the correct output in the terminal.

game.py
class Game:
    def __init__(self):
        self.current_score = [0, 0]

    def score(self, player):
        if player == 1:
            self.current_score[0] += 1
        else:
            self.player_score[1] += 1

1 Answer

Oscar Rojas
Oscar Rojas
4,195 Points

Else should be self.current_score[1] += 1

Ulises Zamora
Ulises Zamora
10,589 Points

Thanks Oscar, that explain why in the workspace work, but not in the challenge.