72. Problem to remove duplicate sublists from the list.

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

Remove duplicate sublists:

Steps to solve the program
  1. Take a list of sublists as input.
  2. Add the sublists from the given list to another list.
  3. Use for loop for this purpose.
  4. If a sublist repeats do not add it to the other list use an iif statement for this purpose.
  5. Print the list to see the output.
				
					#Input list
list1 = [[1, 2], [3, 5], [1, 2], [6, 7]]
list2 = []

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

#Printing output
print(list2)
				
			

Output :

				
					[[1, 2], [3, 5], [6, 7]]
				
			

Related Articles

Elements are unique or not from the given list

Create a list by taking an alternate item

Leave a Comment