Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created August 10, 2020 00:47
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/6f8e4380eb1a59da3157b568114c615c to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/6f8e4380eb1a59da3157b568114c615c to your computer and use it in GitHub Desktop.
l1=[1,'a',2,'b',3,'c',4,'d']
#Creating list containing keys alone by slicing
l2=l1[::2]
#Creating list containing values alone by slicing
l3=l1[1::2]
#merging two lists uisng zip()
z=zip(l2,l3)
#Converting zip object to dict using dict() constructor.
print (dict(z))
#Output:{1: 'a', 2: 'b', 3: 'c', 4: 'd'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment