Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bifurcate_by.py
- def bifurcate_by(lst, fn):
- t = [[],[]]
- for x in lst:
- if x[0] == 'b':
- t[0] += [x]
- else:
- t[1] += [x]
- return t
- t = bifurcate_by(['beep', 'boop', 'foo', 'bar'], lambda x: x[0] == 'b')
- print(t)
- # [ ['beep', 'boop', 'bar'], ['foo'] ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement