Kodewick
开始学 →
小挑战←→0 / 80

运动会积分榜

#046小挑战排序列表约 6 分钟

运动会的队伍记成 (队名, 积分)。写 standings(teams),积分高的在前;积分一样时,队名按字母顺序。返回队名的列表;没有队伍返回 []。

示例
standings([("Red", 6), ("Blue", 9), ("Gold", 6)])→['Blue', 'Gold', 'Red']
standings([])→[]
main.py
def standings(teams):
    # 在这里写:key 返回一个元组:先是负的积分,再是队名
    ordered = teams
    return [name for name, points in ordered]
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。