Skip to content

Instantly share code, notes, and snippets.

@IndhumathyChelliah
Created July 10, 2020 22:28
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/4a786a285966de04a471910ce50fdad2 to your computer and use it in GitHub Desktop.
Save IndhumathyChelliah/4a786a285966de04a471910ce50fdad2 to your computer and use it in GitHub Desktop.
#creating dictionary by using dict()constructor - mapping
d=dict({'red':1,'blue':2,'green':3})
print (d) #Output:{'red': 1, 'blue': 2, 'green': 3}
#creating dictionary by using dict()constructor - mapping. keyword arguments can also be passed.
d=dict({'red':1,'blue':2},green=3)
print (d) #Output:{'red': 1, 'blue': 2, 'green': 3}
#without dict() constructor
d={'red':1,'blue':2,'green':3}
print (d)#Output:{'red': 1, 'blue': 2, 'green': 3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment