python logo

Dictionaries

Dictionaries using key-value pair for the elements Example of a Dictionary animals = { "marshmallow":"a black dog who likes to bark at things", "rudolph":"the very shiny red-nosed reindeer", "doraemon":"a cat with a pocket to access very advanced technological stuffs from the future" } I can use dir function to list the built-in methods and functions I can use to work with Dictionaries animals = { "marshmallow":"a black dog who likes to bark at things", "rudolph":"the very shiny red-nosed reindeer", "doraemon":"a cat with a pocket to access very advanced technological stuffs from the future" } print(dir(animals)) I can use keys method to see all the keys in a dictionary animals = { "marshmallow":"a black dog who likes to bark at things", "rudolph":"the very shiny red-nosed reindeer", "doraemon":"a cat with a pocket to access very advanced technological stuffs from the future" } print(animals....

February 22, 2022 · 3 min · Kei