fruits is a list of fruit names, each starting with an upper case letter.
Write group_fruits(fruits) that groups the names by their first letter and
returns a dictionary in which each key is a first letter and the matching value is
the list of names starting with that letter, sorted in ascending order.
The keys appear in the order in which their letters are first seen in fruits.
An empty list gives an empty dictionary.
Example
group_fruits(['Apple', 'Avocado', 'Banana', 'Cherry']) returns
{'A': ['Apple', 'Avocado'], 'B': ['Banana'], 'C': ['Cherry']}.
Implement this function:
def group_fruits(fruits: list) -> dict:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: fruits.
Input
['Apple', 'Avocado', 'Banana', 'Blueberry', 'Cherry']
Output
{'A': ['Apple', 'Avocado'], 'B': ['Banana', 'Blueberry'], 'C': ['Cherry']}