How to Concatenate Two Dictionaries Into One in Python


In this example, we will learn how to put two dictionaries connected into a dictionary.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

dict1 = {'a': 11, 'b': 22}
dict2 = {'c': 33, 'd': 44}
dict1.update(dict2)
print("The resulted dictionary is: ", dict1)

Output:

The resulted dictionary is: {'b': 22, 'a': 11, 'd': 44, 'c': 33}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments