An example of using a python dictionary to count words in a file.
You can read all about in the code's docstring :