Programming with Python

  1. Home
  2. Docs
  3. Programming with Python
  4. Dictionaries in python
  5. Introduction of Dictionaries

Introduction of Dictionaries

Among the built-in python data type is a very versatile type called a dictionary. Dictionaries are simply another type of collection in python, but with a twist.

A dictionary is set of unordered key-value pairs. In a dictionary, the keys must be unique, and they are stored in an unordered manner.

Dictionaries are mutable. Dictionaries are containers that associate keys to values.

To build a dictionary, separate the key-value pairs by a colon(‘:’). The keys would need to be of an immutable type, i.e. datatypes for which the keys cannot be changed at runtime such as int, string, tuple, etc.
The values can be of any type. Individual pairs will be separated by a comma(‘,’) and the whole thing will be enclosed in curly braces({….}).


dictionary={'key1':'value1','key2':'value2', ....}


Output- class <dict>

Was this article helpful to you? Yes No

How can we help?