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 __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.