Skip to content

Instantly share code, notes, and snippets.

@mdiener21
Created November 4, 2017 06:59
Show Gist options
  • Save mdiener21/deceab862f0ac5bea6e2e52db5446db7 to your computer and use it in GitHub Desktop.
Save mdiener21/deceab862f0ac5bea6e2e52db5446db7 to your computer and use it in GitHub Desktop.
Map two lists into a dictionary ordered by keys
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