keep
keep(items: Iterable[In], fn: Callable[[In], bool])Keep elements in items where fn returns True.
The difference to the built-in filter() is the order of the arguments, and that the output is always a list.
Parameters
items : Iterable[In]-
The sequence of items, such as a list, array, or dict.
fn : Callable[[In], bool]-
The function with a condition that outputs a
bool, which determines which items to keep.
Returns
list[In]-
A list of the kept items.