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

dmitriy ignatiev
seal-mask
.a{fill-rule:evenodd;}techdegree
dmitriy ignatiev
Python Web Development Techdegree Student 1,789 Points

score Method

Hi, could you please tell me what is wrong with my code, it is doesn't work

game.py
class Game:

    def get_score(self, current_score):
        current_score = input('Give a score')

        if current_score in 1 or 2:
            if current_score == 1:
                current_score[0] += current_score
                return current_score
            elif current_score == 2:
                current_score[1] += current_score
                return current_score
            else:
                return self.get_score()

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

        for key, value in kwargs.items():
          setattr(self, key, value)

1 Answer

Jackson Lai
Jackson Lai
3,538 Points

I think you misunderstood the question and go to deep with it.

Here is my solution: It's just simple as this

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

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