Transcript for:
How to Merge Dictionaries in Python

hey guys this is abhishek and uh welcome to the next video and in this video i will show you how you can merge two dictionaries into one let me first correct this two all right so we have two dictionaries sales one sales two and we want to merge them well you can merge it within the single line uh within a single line if you are using python 3.5 and higher okay so what i'm showing you is one quick trick so sales is equals to open and close the dictionary and then use these two stars right this is a new uh basically a way that have been introduced into the python 3.5 to get all the values within the dictionary so sales one and then star sales 2 as well as at other you know in case of functions even you can specify this and can get the multiple different types of parameters acceptance so i would recommend that you read about the new python documentation which is 3.5 about this to get the more idea but what it is doing is it is getting all the list of values over here and then within that dictionary we are combining it into a one all right sales one and two does not exist i'll just execute it should exist now sales i have the dictionary combined into one okay after that um if you are not using python 3.5 then what you need to do so first of all you will say sales is equals to say 1 dot sales 1 not copy to create a copy of it and then you will say sales dot update sales 2. once you do that see the sales so that's a method for those guys who are using the lower version of python 3.5 and you will see i have the values from both the list so that's how you can concatenate or merge two different lists into one okay quiz time merge dictionary create a dictionary web courses and set their keys as html hx and jengle and the prices as three thousand four thousand and five thousand after that you need to merge this new dictionary with the existing dictionary where you have the python or programming etc courses if you find any difficulty in doing this exercise then just watch the video again because i have explained this to you also even after that you find any question or you have any question related to this then let me know in the comments and i will respond to you with that i'll meet you in the next topic