In this python tuple program, we will add an item to a tuple.
Steps to solve the program
- Create a tuple.
- Convert the tuple into a list using list().
- Now add an item to the list using append().
- Then convert the list into a tuple using tuple().
- Print the output.
tup = (18,65,3,45)
print("Old tuple: ",tup)
tup = list(tup)
tup.append(15)
tup = tuple(tup)
print("New tuple: ",tup)
Output :
Old tuple: (18, 65, 3, 45)
New tuple: (18, 65, 3, 45, 15)
1 thought on “Python tuple program to add an item to a tuple”