Closed defterade closed 5 years ago
Category:
Also removes unnecessary list cast.
There are also unnecessary semicolons in the examples section of this function.
def group_by(lst, fn): groups = {} for key in list(map(fn,lst)): groups[key] = [item for item in lst if fn(item) == key] return groups
def group_by(lst, fn): return {key : [el for el in lst if fn(el) == key] for key in map(fn,lst)}
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for any follow-up tasks.
Category:
Description
Also removes unnecessary list cast.
There are also unnecessary semicolons in the examples section of this function.
Current Snippet Behavior
Possible Solution