Introduction to Tuples
Tuples in Python are similar to lists but with one key difference: they are immutable. Once a tuple is created, its contents cannot be changed. Tuples are used to store multiple items in a single variable, and they are ordered collections of items.
Key Properties of Tuples:
- Ordered: Tuples maintain the order of elements.
- Immutable: Once created, the items in a tuple cannot be modified, added, or removed.
- Allows Duplicates: Tuples can contain duplicate elements.
- Dynamic Size: The size of a tuple can change, but its contents cannot.