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

help (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])

http://teamtreehouse.com/library/str

5 Answers

Hi Lyric,

I googled this.

Jeff

i saw that too but it still didnt work for me

Here'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.

Here'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)

Getting 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)

Ok found it, it was spacing between collon and score