我正在做一个在线课程来提高python的水平,其中一个问题是没有通过我不知道是代码还是站点解释器错了
我得到了以下指示
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). You do not need to define self.score. It comes from the Game class.
这是我的密码
from game import Game
class GameScore(Game):
def __Str__(self):
return "Player 1: %s Player 2: %s" %(self.score[0], self.score[1])
我得到这个错误
Expected "Player 1: 5; Player 2: 2". Got "<__main__.GameScore object at 0x7f56c2a04b38>".
问题似乎是大写:您需要
__str__
,但将您的方法命名为__Str__
相关问题 更多 >
编程相关推荐