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
- Take a list of sublists as input.
- Add the sublists from the given list to another list.
- Use for loop for this purpose.
- If a sublist repeats do not add it to the other list use an iif statement for this purpose.
- 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
Python program to create a list by taking an alternate item from the list.
Python program to remove duplicate tuples from the list.
Python program to insert an element before each element of a list.
Python program to remove the duplicate string from the list.
Python program to get the factorial of each item in the list.
Python program to get a list of Fibonacci numbers from 1 to 20.