-
-
Save IndhumathyChelliah/86ca687258ea86abbc8ba9437a003355 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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