Collections
In Python, a collection is the other big family of datatypes for variables. These datatypes also called arrays they can contain mutliple values.
There are 4 types of collections and they have each one different modalities in which they are create and they operate with the data the contain.:
Here’s a table that summarizes the main characteristics of each collection:
| Collection Type | Ordered | Mutable | Duplicate Elements | Indexing | Example |
|---|---|---|---|---|---|
| List | Yes | Yes | Yes | Yes | [1, 2, 3] |
| Tuple | Yes | No | Yes | Yes | (1, 2, 3) |
| Set | No | Yes | No | No | {1, 2, 3} |
| Dictionary | No | Yes | Yes (Values) | Yes | {‘a’: 1, ‘b’: 2, ‘c’: 3} |