我有一个像这样的数组...
[['Abradolf Lincler', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Rick Sanchez', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Tophat Jones', 4, 3], ['Rick Sanchez', 4, 3], ['Rick Sanchez', 4, 3], ['Tophat Jones', 4, 3], ['Xenon Bloom', 4, 4], ['Jerry Smith', 4, 4], ['Xenon Bloom', 4, 4], ['Jerry Smith', 4, 4], ['Xenon Bloom', 4, 4], ['Xenon Bloom', 4, 4], ['Jerry Smith', 4, 4], ['Jerry Smith', 4, 4], ['Xenon Bloom', 4, 4], ['Jerry Smith', 4, 4], ['Jerry Smith', 4, 4], ['Jerry Smith', 4, 4], ['Summer Smith', 4, 4], ['Summer Smith', 4, 4], ['Summer Smith', 4, 4]]
我拥有了这样的球员分数,就像这样...
grouped_scores = {}
for name, score, group_number in scores:
if name not in grouped_scores:
grouped_scores[name] = score
else:
grouped_scores[name] += score
但是我现在也希望能够查看每个组的编号,并能够根据得分输出每个组的获胜者。不知道该怎么做。 我尝试在当前上面的代码中进行另一个for循环,但这不起作用。请帮助