zxznsjdsj 2020-05-03
def bifurcate_by(lst, fn): print(lst) # [‘beep‘, ‘boop‘, ‘foo‘, ‘bar‘] print(fn(‘baby‘)) # True print(fn(‘abc‘)) # False print([ [x for x in lst if fn(x)], [x for x in lst if not fn(x)] ]) bifurcate_by( [‘beep‘, ‘boop‘, ‘foo‘, ‘bar‘], lambda x: x[0] == ‘b‘ ) # [[‘beep‘, ‘boop‘, ‘bar‘], [‘foo‘]]