3.2.1 Tuple Definition and Immutability
A tuple is defined using parentheses, with elements separated by commas.
Once a tuple is created, its contents cannot be changed.
Defining a Tuple
Tuples can contain:
- Numbers
- Strings
- Other data types
- Mixed values
The order of elements is preserved.
Immutability
Immutability means:
- Elements cannot be added, removed, or modified
- The tuple structure remains constant
- Data integrity is preserved
This makes tuples suitable for fixed data collections.
📌 Note:
Attempting to modify a tuple will result in an error.