the initialization involves defining set of key-value pairs to populate the dictionary dictionary is simply an unordered collection of such key-value pairs we are used to looping over lists to access the individual elements we can do the same with dictionarieswith the small but important difference that looping over dictionary means looping over its keysand not the values if we want to access the values we need to look them up in the dictionary using the keys for instancegeneric code to print all the values of dictionary would appear as followsfor key in dictionaryvalue dictionary[keyprint(valuea concrete example based on the example above could look like temps {'oslo' 'london' 'paris' 'madrid' for city in tempsprint( 'the {citytemperature is temps{city}'with the following outputthe paris temperature is the oslo temperature is the london temperature is the madrid temperature is as mentioned abovea dictionary is an unordered collection of key-value pairsmeaning that the sequence of the keys in the dictionary is arbitrary if we want to print or otherwise process the elements in particular orderthe keys first need to be sortedfor instanceusing the built-in function sortedfor city in sorted(temps)value temps[cityprint value alphabetic sort of keys there can be applications where sorting the keys in this manner is importantbut usually the order of dictionary is insignificant in most applications where the order of the elements is importanta list or an array is more convenient data type than dictionary dictionaries and lists share many similarities much of the functionality that we are familiar with for list also exists for dictionaries we canfor instancecheck if dictionary has particular key with the expression key in dictwhich returns true or falseif 'berlinin tempsprint('berlin:'temps['berlin']elseprint('no temperature data for berlin'no temperature data for berlin 'osloin temps standard boolean expression