Collections in Python are containers that are used to store collections of data. Python has built-in collections those are
List | Tuple |
Range | Set |
Frozen Set | Dictionary |
- A list is declared in square brackets, it is mutable and elements can be accessed using indexes and duplicate value’s allowed and Order is preserved.
- tuple is declared in square parenthesis and tuple is ordered and immutable in nature, although duplicate entries can be there inside a tuple.
- A set is unordered and declared in square brackets. It is not indexed and does not have duplicate entries as well.
- A Frozen Set is Immutable and in frozen set index and slice are not there.
- A dictionary has key value pairs and is mutable in nature. We use square brackets to declare a dictionary.
- Range data type represents a sequence of value’s. Range always Immutable nature.