Skip to main content

Posts

Showing posts with the label dict

Dictionary on Python Hunter by Pran Sukh

We have learned about list in previous blogs, list can contain dictionary object vice versa. Both has the ability to change their size at run time. list and dictionary can grow and shrink according to elements at run time. But what is the actual difference b/w these two? Read below.  One is that elements from list object contains elements in linear manner but the dictionary object contains elements as key and value pair.   Elements from list object are fetched with element's location but in dictionary the elements is fetched with key. Last but not the least that list is an ordered object means when the list object is printed it shows the elements as these were inserted but dictionary sort the keys and print the values.      Examples:-  1 2 3 dict_ = dict () dict_ = { "Python" : "Hunter" , "Is" : "Better" } print (dict_) There are lot of methods to manipulate the dictionary object but some of the met...