Python tuple program to remove duplicates from a tuple

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

Steps to solve the program
  1. Take a tuple as input.
  2. Use set() on the tuple to remove duplicates from it.
  3. After using the set() convert the outcome to a tuple using tuple().
  4. Print the output.
				
					tup = (6,4,9,0,2,6,1,3,4)
print("Original tuple: ",tup)
new_tup = tuple(set(tup))
print("New tuple: ",new_tup)
				
			

Output :

				
					Original tuple:  (6, 4, 9, 0, 2, 6, 1, 3, 4)
New tuple:  (0, 1, 2, 3, 4, 6, 9)
				
			

find the tuples with positive elements.

extract digits from a list of tuples.

Leave a Comment