Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created Jul 10, 2020
Embed
What would you like to do?
#creating dictionary by using iterables
d=dict([('red',1),('blue',2),('green',3)])
print (d)#Output:{'red': 1, 'blue': 2, 'green': 3}
#creating dictionary using iterables and keyword arguments
d=dict([('red',1),('blue',2)],green=3)
print (d)#Output:{'red': 1, 'blue': 2, 'green': 3}
#creating dictionary by using zip().zip() also creates iterbales
d=dict(zip(['red','green','blue'],[1,2,3]))
print (d)#Output:{'red': 1, 'green': 2, 'blue': 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment