Discuss / Python / 打卡

打卡

Topic source

人渣14396

#1 Created at ... [Delete] [Delete and Lock User]
L = [('Bob', 75), ('Adam', 92), ('Bart', 66), ('Lisa', 88)]
def by_name(t):
    a=list(j for i in t for j in i if type(j)==str)
    return sorted(a)
print(by_name(L))

def by_score(t):
    a = list(j for i in t for j in i if type(j) == int)
    return sorted(a,reverse=True)
print(by_score(L))

  • 1

Reply