Computer Science
How can you add an extra element to a tuple ?
Python Tuples
7 Likes
Answer
We can use the concatenation operator to add an extra element to a tuple as shown below. As tuples are immutable so they cannot be modified in place.
For example:
t=(1,2,3)
t_append = t + (4,)
print(t)
print(t_append)
Output:
(1,2,3)
(1,2,3,4)
Answered By
4 Likes