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 find the uniqueness of a pair. 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 Unique status of elements is [False, False, False, True, False, True]
- Python | Get unique values from a list
- Python | Get unique tuples from list
- Python | Assign ids to each unique value in a list
- Python | Count unique sublists within list
- Python | Assign value to unique number in list
- Python | Check if list contains all unique elements
- Python | Unique dictionary filter in list
- Python | Get Unique values from list of dictionary
- Python - Get a sorted list of random integers with unique elements
- Python | Extract unique tuples from list, Order Irrespective
- Python | Top N pairs by Kth element from list
- Python - Product of consecutive pairs in list
- Python | Make pair from two list such that elements are not same in pairs
- Python | Maximum of Product Pairs in Tuple List
- Python program to find sum of absolute difference between all pairs in a list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.