Dictionary in Python

In this exercise, we will learn about Python dictionaries; how they are created, accessing, adding, removing elements from them and various built-in methods.

Python dictionary is an unordered collection of items. Each item of a dictionary has a key/value pair. Dictionaries are optimized to retrieve values when the key is known.

Creating Python Dictionary To create a dictionary in python, place items inside curly braces {} separated by commas. The items contains the ‘Key Value’ pairs enclosed within curly braces and Keys and values are separated with ‘:’ colon.

Syntax dictionary_name = {key: value, key2: value2}