For example i have following
list = [[\'1\', \'2\'], [\'1\', \'3\'], [\'1\', \'4\'], [\'1\', \'5\'], [\'2\', \'1\'], [\'4\', \'1\'], [\'2\', \'6\']]
Approach1:
new_list = []
for l in List:
if l not in new_list and sorted(l) not in new_list:
new_list.append(l)
print(new_list)
Approach2:
You can try like this also:
seen = set()
print([x for x in List if frozenset(x) not in seen and not seen.add(frozenset(x))])
[['1', '2'], ['1', '3'], ['1', '4'], ['1', '5'], ['2', '6']]