Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created August 9, 2020 23:51
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/328d97fd8ac1484c0608542f0edc0afc to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/328d97fd8ac1484c0608542f0edc0afc to your computer and use it in GitHub Desktop.
from itertools import zip_longest
l1=[1,2,3,4,5,6,7]
l2=['a','b','c','d']
d1=zip_longest(l1,l2)
print (d1)#Output:<itertools.zip_longest object at 0x00993C08>
#Converting zip object to dict using dict() contructor.
print (dict(d1))
#Output:{1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: None, 6: None, 7: None}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment