Update snippet descriptions
This commit is contained in:
@ -3,10 +3,10 @@ title: bifurcate
|
||||
tags: list,intermediate
|
||||
---
|
||||
|
||||
Splits values into two groups.
|
||||
If an element in `filter` is `True`, the corresponding element in the collection belongs to the first group; otherwise, it belongs to the second group.
|
||||
Splits values into two groups, based on the result of the given `filter` list.
|
||||
|
||||
- Use list comprehension and `zip()` to add elements to groups, based on `filter`.
|
||||
- Use a list comprehension and `zip()` to add elements to groups, based on `filter`.
|
||||
- If `filter` has a truthy value for any element, add it to the first group, otherwise add it to the second group.
|
||||
|
||||
```py
|
||||
def bifurcate(lst, filter):
|
||||
@ -17,5 +17,6 @@ def bifurcate(lst, filter):
|
||||
```
|
||||
|
||||
```py
|
||||
bifurcate(['beep', 'boop', 'foo', 'bar'], [True, True, False, True]) # [ ['beep', 'boop', 'bar'], ['foo'] ]
|
||||
bifurcate(['beep', 'boop', 'foo', 'bar'], [True, True, False, True])
|
||||
# [ ['beep', 'boop', 'bar'], ['foo'] ]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user