Python tuple program to add an item to a tuple

In this python tuple program, we will add an item to a tuple.

Steps to solve the program
  1. Create a tuple.
  2. Convert the tuple into a list using list().
  3. Now add an item to the list using append().
  4. Then convert the list into a tuple using tuple().
  5. 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)
				
			

assign values of tuples to several variables and print them.

convert a tuple into a string.

1 thought on “Python tuple program to add an item to a tuple”

Leave a Comment