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

Hope Mallary
Hope Mallary
900 Points

player

player argument

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

    def score(player):

        if player ==1:
            self.current_score + 1

        else:
            player == 2
            self.current_score = 2

1 Answer

A few issues with your code:

First, make sure your indentation is correct. Python will give errors if your indentation is off.

Second, all instance methods (in this case the score() method) need to have a parameter of self in addition to any other parameters the method requires.

Third, the challenge indicates that player 1 is the 0th index of the current_score variable, so you need an index after the current_score variable in your score() method. You will need an index after both current_score variables: one for player 1 and one for player 2.

Fourth, when incrementing the current_score variable you need to use += 1.

Finally, the challenge indicates that you are supposed to increment the score for both players by just 1, not 2 as you have for player 2.

I wanted to just give you some pointers to help you fix the code yourself. Good luck!