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
Lyric Abbott
35,595 Pointshelp (EDITED)
Add a str method to GameScore that returns the score in the string "Player 1: 5; Player 2: 10", using the correct values from self.score. self.score is a tuple with Player 1's score and Player 2's score like (5, 10).
My code:
from game import Game class GameScore(Game): pass def str(self): return "Player 1: {5}; Player 2: {10}".format(self.score[5], self.score[10])
5 Answers
Jeff Busch
19,287 PointsJeff Busch
19,287 PointsHere's the code
from game import Game
class GameScore(Game):
def __str__(self):
return "Player 1: {}; Player 2: {}".format(self.score[0], self.score[1])
Now correct it like Kenneth Love suggests:
Kenneth Love 3,313 STAFF about 1 month ago
Looks like you didn't indent the body of the function.
I used it and passed both challenges.
james white
78,399 PointsHere's what passed for me:
from game import Game
class GameScore(Game):
def __str__(self):
self.score = (5, 2)
return "Player 1: {}; Player 2: {}".format(*self.score)
MUZ140804 Micheal Matiashe
2,779 PointsGetting this error Bummer! Expected "Player 1: 5; Player 2: 2". Got "Player 1:5; Player 2:2".
from game import Game
class GameScore(Game): def str(self): return "Player 1:{}; Player 2:{}".format(*self.score)
MUZ140804 Micheal Matiashe
2,779 PointsOk found it, it was spacing between collon and score
Lyric Abbott
35,595 PointsLyric Abbott
35,595 Pointsi saw that too but it still didnt work for me