Python tuple program to remove an item from a tuple

In this python tuple program, we will remove an item from a tuple.

Steps to solve the program
  1. Create a tuple.
  2. Now convert that tuple to a list using list().
  3. Remove the element from the list.
  4. Again convert the list to a tuple using tuple().
  5. Print the output.
				
					tup = ('p','y','t','h','o','n')
print("Original tuple: ",tup)
l = list(tup)
l.remove('h')
tup = tuple(l)
print("After removing an element: ",tup)
				
			

Output :

				
					Original tuple:  ('p', 'y', 't', 'h', 'o', 'n')
After removing an element:  ('p', 'y', 't', 'o', 'n')
				
			

convert a list into a tuple and multiply each element by 2.

program to slice a tuple.

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

Leave a Comment