Discuss / Python / 练习二

练习二

Topic source

Teresa委

#1 Created at ... [Delete] [Delete and Lock User]
L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
def by_score(t):
    return -t[1] #变成负数就能从高到低排列了
L2 = sorted(L, key=by_score)
print(L2)

活力老汤

#2 Created at ... [Delete] [Delete and Lock User]

厉害!


  • 1

Reply