From d88cbc42c4e58b51a2d34b3700b4cd23eb8c617e Mon Sep 17 00:00:00 2001 From: Abhishek <55457501+Abhishek-Dobliyal@users.noreply.github.com> Date: Fri, 2 Oct 2020 10:30:08 +0530 Subject: [PATCH] Added shorthand to merge dicts --- Basics/dict_tuple.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Basics/dict_tuple.py b/Basics/dict_tuple.py index 382450a6..1d4d73fb 100644 --- a/Basics/dict_tuple.py +++ b/Basics/dict_tuple.py @@ -34,6 +34,15 @@ def age_dictionary(): else: print ("I don't know the age of",name) print ("Age dictionary program is finished now") + +### Merge Two or More Dicts (ShortHand) + +dict1 = {"Fruit": "Apple", "Color": "Red"} +dict2 = {"Car Name": "XC90", "Manufaturer": "Volvo"} +dict3 = {"SmartPhone": "Android", "Brand": "Oneplus"} + +final_dict = {**dict1, **dict2, **dict3} +print(final_dict) # Exercise 1 age_dictionary()