Python Trick to merge two dictionaries | #coding #shorts #programming

preview_player
Показать описание
Python Trick to merge two dictionaries together
Here is a fantastic Python approach. Do you have 2 dictionaries that you’d like to merge easily? You can use ** notation for **kwargs-like objects (values with names like dictionaries) to merge them conveninently.

Let’s say you have 2 Olympics results from 2 separate countries that held the events. Dictionary 1 named: China_olympics and then Japan_olympics and you’d like to make a shallow merge. All you have to do is:

{**China_olympics, **Japan_olympics}

Python will take care of the rest, making it a breeze.

#coding #shorts #programming
#pythonTricks #pythontips #python2022 #learnpython
Рекомендации по теме