例2.13 数据分组

例2.13 数据分组


def bifurcate_by(L,fn):
    return [[x for x in L if fn(x)],
             [x for x in L if not fn(x)]]
s = bifurcate_by(['beep','boop','foo','bar'],lambda x:x[0]=='b')
print(s)

print("学号:3004")

posted on 2024-09-06 14:41  黄元元  阅读(5)  评论(0编辑  收藏  举报