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

Kim Lam
PLUS
Kim Lam
Courses Plus Student 2,801 Points

What is this challenge trying to ask me to do?

The challenge task is: Add a score method to Game that takes a player (1 or 2) and increases that current_score member's score by 1.

Specifically, what kinds of inputs should I expect for this method? A re-wording of this question is: How will this method be called? For example, self.score(), or self.score(1) or self.score(2)?

What does the challenge refer to when it says "current_score member's score"?

What objects will be made with the class Game? (Is it Player 1 and Player 2?) If so, will each player object have their own current_score attribute?

This code challenge is probably simpler than it seems, since there are no comments with any further hints or explanations. I'm probably just missing something that's extremely obvious to most other people, or the general populace as a whole.

I have re-watched the previous video, and fiddled a lot with a text-editor, and the only two errors I've received were Bummer! Try again! and syntax error. Which feeds into why I think it's a very simple code challenge that probably doesn't need any explanation, but here I am, asking for one anyway.

Thank you for your time!

1 Answer

Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

current_score is a list of two items with both items being 0. current_score[0] is Player 1, current_score[1] is Player 2. If we call score(1), Player 1's score should go up. Same for Player 2 if we call score(2).

Kim Lam
Kim Lam
Courses Plus Student 2,801 Points

Oh wow, it's you! xD Mm... thank you; it's a lot clearer. I tried using the code I thought would work. And then I figured it out! Thank you, Kenneth Love!