Assuming:
a = [(1,2,3),(4,5,6)]
b = [(4,5,6),(1,2,3)]
I want the following comparison to be True. Meaning position of tuple inside list doesn't matter.
a == b
Assuming:
a = [(1,2,3),(4,5,6)]
b = [(4,5,6),(1,2,3)]
I want the following comparison to be True. Meaning position of tuple inside list doesn't matter.
a == b
Create a multiset - collections.Counter
object in Python - from both lists and compare those:
>>> from collections import Counter
>>> a = [(1,2,3), (4,5,6)]
>>> b = [(4,5,6), (1,2,3)]
>>> Counter(a) == Counter(b)
True
Sort the lists, then compare them:
a = [(1,2,3),(4,5,6)]
b = [(4,5,6),(1,2,3)]
sorted(a)==sorted(b)
# True
If you don't care about repetitions, use sets: set(a) == set(b)
Otherwise, sort them: sorted(a) == sorted(b)