Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Object-Oriented Python (retired) Inheritance __str__

Christian Tielking
Christian Tielking
669 Points

GameScore is not producing the right output

I'm confused, it told me to use str to return the player 1 score and player 2 score. I tried it just like the directions show and how we did it in the class. can someone please scan the code and see what the bug is?

game_str.py
from game import Game

class GameScore(Game):
    def __str__(self):
        return "Player 1:{}; Player 2:{}".format(self.score, self.score)

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

you are trying to format with self.score twice. it tells you that self.score is a tuple with both players scores as its elements. you can slice into a tuple just like a list or string, with the [].