Tuple In Python-
- – Maintaining the insertion order.
- – Tuple can store duplicate and heterogeneous values.
- – Tuples can also be processed by slicing and indexing.
- – Tuple is a immutable collection. Means we can’t modify the tuple as soon as it is created.
- – Tuple doesn’t have modification function like(pop, append, remove).
- – Tuple has only two functions count and index.
- – Tuple elements can be mutable or immutable.
- – We can store a list as an element inside the tuple and can modify this list as well.
Ex –
t = (7, 2, 'Python', 3, 3.4)
print(t)
Output-
(7, 2, 'Python', 3, 3.4)
t = (7, 2, 'Python', [3, 3.4])
print(t)
Output-
(7, 2, 'Python', [3, 3.4])