Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
defaultdict(set) solution in Clear category for Switch Keys to Values by juestr
from collections import defaultdict
def switch_dict(data: dict) -> dict:
result = defaultdict(set)
for k, v in data.items():
result[v].add(k)
return result
Sept. 19, 2022
Comments: