Python

Python Dictionary Operations You Should Know

Jacob Ferus
2 min readApr 20, 2022
Image generated by Jacob Ferus

The dictionary/dict is one of the basic data structures in Python. It is truly at the core of Python and is used everywhere. Furthermore, it is the corresponding object for JavaScript’s objects and in turn JSON. Here I will list several useful operations and methods related to it.

Initialization

There are two common ways of initializing dictionaries:

I prefer the second way because it is easier to type, avoiding brackets and quotation marks.

Merging dictionaries

Merging dicts is easy. Additionally, you can control what happens when you merge objects with identical attributes with the order.

Dictionary comprehension

--

--

Jacob Ferus

Looking outside the box and making sense of the world using data.