Skip to content

Instantly share code, notes, and snippets.

@kzinmr
Created December 26, 2018 02:22
Show Gist options
  • Save kzinmr/a577291d08576d776224df4d6db41527 to your computer and use it in GitHub Desktop.
Save kzinmr/a577291d08576d776224df4d6db41527 to your computer and use it in GitHub Desktop.
from collections import defaultdict
def dict_of_list(keys, values):
assert(len(keys) == len(values))
key2values = defaultdict(list)
for k, v in zip(keys, values):
key2values[k].append(v)
return key2values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment