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 trialDavid Hackett
3,191 PointsI am not sure why I am getting a self.score.self.score... what does this mean?
I am not sure what I am supposed to do here... can I just write "Player 1" and "Player 2" or should I be pulling this from the object somehow?
Bit confused all around really!...
from game import Game
class GameScore(Game):
pass
def __str__(self):
return "Player 1: {}, Player 2: {}".format(self.score.self.score[0], self.score.self.score[1])
8 Answers
Ryan Ruscett
23,309 Pointsahhh I see, yeah no you have to read really slooowwww lol. It says "using the correct values from self.score. PERIOD end of sentence kind of period. New sentence self.score xxxx
I totally see how you thought that tho.
Does that clear it up?
Ryan Ruscett
23,309 PointsWhat is different about these two strings.
Top one is expected bottom one is what you are giving. Notice anything HINT ( ; ) missing.
Player 1: 5; Player 2: 2
Player 1: 5, Player 2: 2
update your return to add the missing character.
Sung Uk Ryu
5,304 PointsI actually copied the string part from the problem itself and it worked magically... -.- Thanks for the truth! :D
Ryan Ruscett
23,309 PointsHey,
So you are close. You are calling the values wrong.
return "Player 1: {}, Player 2: {}".format(self.score.self.score[0], self.score.self.score[1]
Why are you calling it twice for each item. self.score.self.score? You only call it one time. So like this
return "Player 1: {}, Player 2: {}".format(self.score[0], self.score[1]
NOTE - I would recommend saving that as say variable XYZ = blahblah and returning XYZ. That way if something ever goes wrong you can always just add a print statment on XYZ and get the actual value that is being passed. Helps if you use repr too. Least for me.
That's all you have to do differently. There is one other error that will be way to clear when you see it about your string. You are missing a ; inside the string.
Let me know if you have any other issues I can clear up.
David Hackett
3,191 PointsI was calling it twice as the question seemed to suggest to do that...
Here is the question as it was presented to me: "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)."
... so the "self.score.self.score" in there had me confused- why is it like that? (or is that a mistake??)
Sung Uk Ryu
5,304 PointsHi,I have same error and don't know why.
I tried both
from game import Game
class GameScore(Game):
def __str__(self):
return "Player 1: {}, Player 2: {}".format(*self.score)
and
from game import Game
class GameScore(Game):
def __str__(self):
return "Player 1: {}, Player 2: {}".format(self.score[0], self.score[1])
and I got message
Bummer! Expected "Player 1: 5; Player 2: 2". Got "Player 1: 5, Player 2: 2". ?????
for both....
What should I do now -.-
Adanma Ekeledo
15,460 PointsI got this same error. I refreshed the page and it worked.
Vivek Vyas
2,736 PointsBoth of them should work fine. You have typed: return "Player 1: {}, Player 2: {}".format(self.score[0], self.score[1])
Just change this to: return "Player 1: {}; Player 2: {}".format(self.score[0], self.score[1])
Need to add (;) instead of (,) between two players as required and it works fine.
Prashant chaudhari
Courses Plus Student 24,499 Pointsfrom game import Game
class GameScore(Game): def str(self): return "Player 1: {}; Player 2: {}".format(self.score[0], self.score[1])
Casey Huckel
Courses Plus Student 4,257 PointsHow is this wrong? It says Task 1 is no longer passing:
from game import Game
class GameScore(Game): pass
def_str_(self): return "Player 1: {}; Player 2: {}".format(self.score[0] , self.score[1])
Jeremy Kerrigan
12,002 PointsI solved it like this by unpacking the tuple into 2 separate variables x, y
from game import Game
class GameScore(Game):
pass
def __str__(self):
x, y = self.score
return "Player 1: {}; Player 2: {}".format(x, y)
David Hackett
3,191 PointsDavid Hackett
3,191 PointsAhhh... ok, I see where I went down a not so merry path there !
All clear now (and the got the exercise passed)... thanks for the help Ryan =)
Ryan Ruscett
23,309 PointsRyan Ruscett
23,309 PointsNo worries, I do that all the time. The craziest little hang ups.