Sometimes, while working with python list, we can have a binary matrix ( Nested list having 2 elements ). And we can have a problem in which we need to remove unidentical lists. A pair is unique irrespective of order, it doesn’t appear again in list. Let’s discuss certain way in which this task can be performed.
Method : Using
frozenset() + Counter() + list comprehension
The combination of above functions can perform this task. The frozenset() is used for ignoring the ordering, Counter() is used to perform the task of checking the uniqueness and iteration is done using list comprehension.
The original list is : [[5, 6], [9, 8], [8, 9], [1, 4], [6, 5], [10, 1]] The list after removal of unidentical lists : [[5, 6], [9, 8], [8, 9], [6, 5]]
- Python | Remove given element from list of lists
- Python | Remove duplicate lists in tuples (Preserving Order)
- Python | Program to count number of lists in a list of lists
- Python | Zipping two lists of lists
- Python | Iterating two lists at once
- Python - Lists Modulo
- Python | Average of two lists
- Python | All possible permutations of N lists
- Python | Union of Value Lists
- Python | Difference between two lists
- Python | Using 2D arrays/lists the right way
- Python | Dividing two lists
- Python | Intersection of two lists
- Python | Merge key value lists
- Python | Union of two or more Lists
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.