This post explains what is dictionary in Python. The dictionary in Python is the data object, that is indexed with keys, which can be both numbers and strings. Dictionary is presented as a key-value pair.

Dictionary usually represented the following way: dictionary = {key1:value1, key2:value2,...}.

Main operations that can be performed with the dictionaries are:

  • storing key:value pair
  • deleting key:value pair
  • logical identification with the keyword in
  • and others

Interesting method that is applied to dictionaries is get that returns key and a value of the dictionary object.

We can convert elements of the file into dictionary and apply different statement in order to work with dictionary objects, like for or if. We can also use loops to work with dictionary objects.

You can also do text parsing using dictionaries.

Examples of all mentioned above actions with dictionaries you can find in our Github library.