Created
December 26, 2018 02:22
-
-
Save kzinmr/a577291d08576d776224df4d6db41527 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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