I have the list
a = [([4, 7, 9], [3], 5.5), ([2, 5, 8], [3], 5.5), ([3], [4, 7, 9], 5.5), ([3], [2, 5, 8], 5.5)]
and I am trying to remove duplicate tuples that have the same combination of lists.
For example, ([4, 7, 9], [3], 5.5)
and ([3], [4, 7, 9], 5.5)
are the same. So the output after removing the duplicate tuples will look something like:
a = [([4, 7, 9], [3], 5.5), ([2, 5, 8], [3], 5.5)]
with any order of the lists in the tuples allowed.
Edit (based on @DYZ's feedback): Fully flattened tuples are not allowed. For example, (4,7,9,3,5.5)
is not allowed. The output should still be of the form: ([list 1], [list2], constant)
.
I tried to adapt a method that is related in Remove duplicated lists in list of lists in Python, but I have reached a mental deadlock..
Is it possible to modify the code further in the linked question, or is there a more efficient way to do this?