Created
November 4, 2017 06:59
-
-
Save mdiener21/deceab862f0ac5bea6e2e52db5446db7 to your computer and use it in GitHub Desktop.
Map two lists into a dictionary ordered by keys
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
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] | |
dictionary = dict(zip(keys, values)) | |
#result looks like this {'a': 1, 'b': 2, 'c': 3} | |
# ordered dictionary | |
import collections | |
keys = ['a', 'b', 'c'] | |
values = [1, 2, 3] | |
dictionary = collections.OrderedDict(zip(keys, values)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment