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!
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

shivanand ingalagavi
1,409 Points__str__
Add a str method
from game import Game
class GameScore(Game):
pass
def __str__():
return "Player {}; Player {}".format(self.score, self.score)
1 Answer

Steven Parker
225,730 PointsHere's a few hints:
- you won't need pass anymore when you define the method
- you forgot to include the player numbers followed by colons in the literal string
- since self.score is a tuple, you'll need to use indexing to get the individual player scores
- a method should indicate self as its first argument
I'll bet you can get it now. But if you're still stuck...
SPOILER ALERT
class GameScore(Game):
def __str__(self):
return "Player 1: {}; Player 2: {}".format(self.score[0], self.score[1])
Chris Freeman
Treehouse Moderator 68,390 PointsChris Freeman
Treehouse Moderator 68,390 PointsBig
on the use of spoiler button. Moderator material!
Chris Freeman
Treehouse Moderator 68,390 PointsChris Freeman
Treehouse Moderator 68,390 PointsKen Alger and Kenneth Love: check out the use of JavaScript in this answer.
Myers Carpenter
6,421 PointsMyers Carpenter
6,421 PointsThanks showing us you could add Javascript in your post. That isn't something we want to allow in the forums as it's a security risk (read more here in the Rails Security Guide). We've fixed the bug and edited your post.
I've added a feature request for a official spoiler button to be added into the forum code as I see it's usefulness.