Collections is a high-performance container datatypes. defaultdict objects class collections.defaultdict([default_factory[, ...]]) #Returns a new dictionary-like object. defaultdict is a subclass of the built-in dict class. #It overrides one method a…