Count grouped elements
Groups the elements of a list based on the given function and returns the count of elements in each group.
- Use 
collections.defaultdictto initialize a dictionary. - Use 
map()to map the values of the given list using the given function. - Iterate over the map and increase the element count each time it occurs.