Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Expected {(3, 2): [(1, 2)]}, but returned {3: [(1, 2)], 2: [(1, 2)]} Expected {'bc': ['ab']}, but returned {'b': ['ab'], 'c': ['ab']} help pls club_functions.py

Expected {(3, 2): [(1, 2)]}, but returned {3: [(1, 2)], 2: [(1, 2)]}

Expected {'bc': ['ab']}, but returned {'b': ['ab'], 'c': ['ab']}

help pls

image text in transcribed
club_functions.py (/Users/jialongyuan/Desktop/a3): Wing E a3testfile.py (r/o) a3_shitchecker_v2.py (r/o)| club_functions.py typing.py recommend_clubs V X 121 122 return dict1 dict1[i] = sorted(list(set(dict1[i])>> 123 124 def invert_and_sort(key_to_value: Dict[object, object]) -> Dict[object, list]: 125 """Return key_to_value inverted so that each key is a value (for 126 non-list values) or an item from an iterable value, and each value 127 is a list of the corresponding keys from key_to_value. The value 128 lists in the returned dict are sorted. 129 130 invert_and_sort(P2C) == { 131 . . . 'Comet Club' : ['Michelle Tanner' ], 132 . . . Parent Council' : ['Danny R Tanner' , 'Jesse Katsopolis' , 133 . . . 'Joey Gladstone' ], 134 . . . 'Rock N Rollers': ['Jesse Katsopolis' , 'Kimmy Gibbler' ], 135 . . . 'Comics R Us' : [' Joey Gladstone' ], 136 . . . Smash Club' : ['Kimmy Gibbler' ]} 137 True 138 1 11 11 139 result = {} 140 for key in key_to_value: 141 for item in key_to_value[key]: 142 if item in result: 143 result[item] . append(key) 144 else: 145 result[item] = 146 result[item] . append(key) 147 for i in result: 148 149 result[i] = sorted(list(set(result[i]))) return result 150 151 def get_clubs_of_friends(person_to_friends: Dict[str, List[str]], 157 nancon to cline. nistletn listletn17 Search Stack Data Debug 1/O Python Shell Search: Replace: Commands execute without debua. Use arrow kevs for history. Options Coco concitive Whale words In Calaction Options "/Users/iialonavuan/Desktop/a3/club functions .ov" . line 141. in invert and sort Line 207 Col 29

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions