Letter Counter

Write a program letter_counter.py that includes two functions:

By the time count_letters has been called repeatedly with a series of text inputs, the dictionary might look something like this:

{'a': 188703, 'h': 60702, 'e': 275582, 'd': 81731, 'i': 220483, 'n': 163637, 'g': 67910, 's': 234672, 'l': 127865, 'r': 170521, 'v': 22521, 'k': 22075, 'w': 18393, 'o': 161752, 'f': 28930, 't': 159471, 'b': 44953, 'c': 98230, 'y': 39772, 'u': 80636, 'm': 70700, 'p': 73286, 'x': 6852, 'j': 4010, 'z': 11772, 'q': 4104}

Write a main() program that takes care of calling those two functions and printing out the final results of some letter counting.

Extension

Dictionaries aren't intended to be ordered--that's why they are so fast. Still, it is sometimes convenient to be able to print out the final contents of a dictionary list in some sort of order.

Import the operator library into your program, and add the following lines to your program after the dictionary is completed.

sorted_lettercounts = sorted(dict.items(), key=operator.itemgetter(1))

This creates a list called sorted_lettercounts that is sorted by the values in the dictionary's key-value pairs. Print this list.