Question: get_last_to_first: (dict[str, list[str]]) -> dict[str, list[str]] The parameter represents a person to friends dictionary. This function must return a last name to first names dictionary

get_last_to_first: (dict[str, list[str]]) -> dict[str, list[str]]

The parameter represents a "person to friends" dictionary. This function must return a "last name to first names" dictionary built from the data in the given dictionary. The keys in the returned dictionary should be the last names of people in the given dictionary. (Remember: every person has exactly one last name.) The values are lists of the first names (sorted in alphabetical order) of people with a given last name.

The returned dictionary should contain every person whose name appears in the given dictionary: the person's last name as one of the dictionary keys, and the person's first name as an element in one of the dictionary values. Names in the list should be unique: no one should be listed more than once. Use method list.sort to put the lists of first names into alphabetical order.

get_last_to_first: (dict[str, list[str]]) -> dict[str, list[str]]The parameter represents a "person to friends"dictionary. This function must return a "last name to first names" dictionary

\f\f

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!