我寫了這個功能:指數錯誤:列表分配索引超出範圍
def replace(self, pos, note):
"""
Replace the score of the participant at the given position with a new score
Input: pos, note - integer
Output: the old score was replaced
"""
scores = self.repo.getAll()
scores[pos] = note
return scores
凡GETALL類participantRepo的定義如下:
def getAll(self):
return self._participantList[:].
我的問題是,我不明白錯誤我不斷收到