74. Problem to remove duplicate tuples from the list.

In this Python list program, we will take a user input as a list and remove duplicate tuples from the list with the help of the below-given steps.

Remove duplicate tuples from list:

Steps to solve the program
  1. Take a list of tuples as input.
  2. Using for loop add the tuples from the given list to another list.
  3. If a tuple repeats then do not add it.
  4. Print the output to see the result.
				
					#Input list
list1 = [(2, 3), (4, 6), (5, 1), (2, 3), (7, 9), (5, 1)]
list2 = []

for value in list2:
    if value not in list2:
        list2.append(value)

#Printing output
print(list2)
				
			

Output :

				
					[(2, 3), (4, 6), (5, 1), (7, 9)]
				
			

Related Articles

Create a list by taking an alternate item.

Insert an element before each element of a list

Leave a Comment