Question
your boy is struggling out here
-------------------------------------------
def
get_last_to_first(
person_to_friends: Dict[str, List[str]]) -> Dict[str, List[str]]:
"""Return a "last name to first name(s)" dictionary with the people from the
"person to friends" dictionary person_to_friends.
>>> get_last_to_first(P2F) == {
... 'Katsopolis': ['Jesse'],
... 'Tanner': ['Danny R', 'Michelle', 'Stephanie J'],
... 'Gladstone': ['Joey'],
... 'Donaldson-Katsopolis': ['Rebecca'],
... 'Gibbler': ['Kimmy'],
... 'Tanner-Fuller': ['DJ']}
True
"""
pass # Remove me when you've implemented this function
def invert_and_sort(key_to_value: Dict[object, object]) -> Dict[object, list]:
"""Return key_to_value inverted so that each key is a value (for
non-list values) or an item from an iterable value, and each value
is a list of the corresponding keys from key_to_value. The value
lists in the returned dict are sorted.
>>> invert_and_sort(P2C) == {
... 'Comet Club': ['Michelle Tanner'],
... 'Parent Council': ['Danny R Tanner', 'Jesse Katsopolis',
... 'Joey Gladstone'],
... 'Rock N Rollers': ['Jesse Katsopolis', 'Kimmy Gibbler'],
... 'Comics R Us': ['Joey Gladstone'],
... 'Stamp Club': ['Kimmy Gibbler']}
True
"""
pass # Remove me when you've implemented this function
Top Answer
Please find the code and output below. Let me know if you have any doubt. from typing import List,Dict def invert_and_sort... View the full answer