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)

posted @ 2024-10-27 23:15  世梦  阅读(20)  评论(0)    收藏  举报