Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Last active August 10, 2020 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IndhumathyChelliah/899ca0d75b21d11be00db94715a39751 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/899ca0d75b21d11be00db94715a39751 to your computer and use it in GitHub Desktop.
l1=[{1:'a',2:'b'},{3:'c',4:'d'}]
from collections import ChainMap
d3=ChainMap(*l1)
print (d3)#Output:ChainMap({1: 'a', 2: 'b'}, {3: 'c', 4: 'd'})
#Converting ChainMap object to dict using dict() constructor.
print (dict(d3))
#Output:{3: 'c', 4: 'd', 1: 'a', 2: 'b'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment