Given a dictionary of groups (each value is a list of items) and a function func, return a dictionary with the same keys where each value is func applied to that group's list.
func is passed in as a real function — len counts the group, sum totals it, max takes its largest item.
Example: {'a': [1, 2, 3], 'b': [4]} with sum gives {'a': 6, 'b': 4}.
Implement this function:
def apply_to_groups(groups: dict, func: callable):
Write the function only — the arguments are read for you and the return value is printed automatically.
Input
{'a': [1, 2, 3], 'b': [4]}
sum
Output
{'a': 6, 'b': 4}