Better way to count elements
Collections module provide a Counter class which can used to count elements in a list. It also provides utility functions like
most_common for getting most common elements in the list.
defaultdict behaves like normal dict with one key difference. It has a factory function that takes no arguments which provides values for non existent key
One most popular example is one liner tree function. You can create a nested dict without even initialising its parents.
namedtuple is a factory function to create tuple like object but can access its elements with attribute name.