Collections Module

StevenSwiniarski's avatar
Published Jul 7, 2022
Contribute to Docs

The collections module implements several container types in addition to the standard Python built-in collections, dict, list, set and tuple.

Below are some of the specialized data types provided by this module.

Collections Module

collections.Counter
A dict subclass that stores counts for hashable objects.
collections.OrderedDict
Tracks the order in which items were added.
defaultdict
Returns a dictionary-like object.
deque()
Creates a deque object.
namedtuple
A tuple subclass with named fields

All contributors

Contribute to Docs

Learn Python on Codecademy