Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python (retired) Inheritance __str__

Elizabeth McInerney
Elizabeth McInerney
3,175 Points

Adding score to game

I do not understand what I am doing wrong here.

game_str.py
from game import Game

class GameScore(Game):
  self.score = 5,10
  return "Player 1: {}; Player 2: {}".format(self.score[0],self.score[1])

4 Answers

Jon Peterson
Jon Peterson
12,661 Points
from game import Game

class GameScore(Game):
  self.score = 5,10
  return "Player 1: {}; Player 2: {}".format(*self.score)
Elizabeth McInerney
Elizabeth McInerney
3,175 Points

Oh man, was that it??? Ugh, yes, I see! Thanks!

Elizabeth McInerney
Elizabeth McInerney
3,175 Points

Hello, I just posted the question again, because I still can't get it to work, even with your code.

Same here, that code would not work as well.

The challenge asks you to define a __str__ method within the GameScore class. It also says:

You do not need to define self.score. It comes from the Game class.

Move your return statement to the new method and you should be good to go. You could also use the format Jon Peterson suggested.