Collections in Python
Python provides several built-in collection types for storing and organizing data.
List
A mutable, ordered sequence of items.
Tuple
An immutable, ordered sequence of items.
Set
An unordered collection of unique items.
Dictionary
A collection of key-value pairs.
The collections Module
The collections
module provides additional data structures:
- deque
: Fast appends and pops from both ends
- Counter
: Counts hashable objects
- defaultdict
: Dictionary with default values
- OrderedDict
: Dictionary that remembers insertion order
- namedtuple
: Factory for tuple subclasses with named fields