dictionary as set of counters suppose you are given string and you want to count how many times each letter appears there are several ways you could do it you could create variablesone for each letter of the alphabet then you could traverse the string andfor each characterincrement the corresponding counterprobably using chained conditional you could create list with elements then you could convert each character to number (using the built-in function ord)use the number as an index into the listand increment the appropriate counter you could create dictionary with characters as keys and counters as the corresponding values the first time you see characteryou would add an item to the dictionary after that you would increment the value of an existing item each of these options performs the same computationbut each of them implements that computation in different way an implementation is way of performing computationsome implementations are better than others for examplean advantage of the dictionary implementation is that we don' have to know ahead of time which letters appear in the string and we only have to make room for the letters that do appear here is what the code might look likeword 'brontosaurusd dict(for in wordif not in dd[ elsed[cd[ print(dwe are effectively computing histogramwhich is statistical term for set of counters (or frequenciesthe for loop traverses the string each time through the loopif the character is not in the dictionarywe create new item with key and the initial value (since we have seen this letter onceif is already in the dictionary we increment [chere' the output of the program{' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' the histogram indicates that the letters "aand "bappear once"oappears twiceand so on dictionaries have method called get that takes key and default value if the key appears in the dictionaryget returns the corresponding valueotherwise it returns the default value for example