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

What are they even asking

I don't really understand what is even being asked. What is supposed to be causing the players to gain points in the method?

game.py
class Game:
    if player == 1:
        self.current_score[0]
    if player == 2:
        self.current_score[1]

    def score(player):

    def __init__(self):
        self.current_score = [0, 0]

1 Answer

Hi Ezekiel Wootton

Basically, when the Game class is initialised it has a current_score of [0,0], each index representing player1 and player2 scores. The challenge wants you to create a method called score which will take a player as an argument, i.e method will take 1 or 2. So when 1 is passed in you increment current_score index 0 by 1 and visa versa. The player gains points when the score method is called.

here is an example of the score method.

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

Hope this makes sense