I'm trying to get symmetric pairs with no duplicates, for example, from
L=[(1,3), (2,6), (3,5), (4,7), (5,3), (6,2), (3,4),(4,3)]
, I want to get like[(2,6), (3,5), (3,4)]
, finding symmetric pairs.
this is my full code,
L=[(1,3), (2,6), (3,5), (4,7), (5,3), (6,2), (3,4),(4,3)]
def find_symmetric_pairs(L):
temp = {}
temp_list = []
for i in L:
key, value = i
for j in L:
key_j, value_j = j
if key == value_j and value == key_j:
temp_list.append(tuple((key,value)))
return temp_list
and also, I'm trying to implement this function by using python hashtable, how can I use hashtable? The output looks like this
[(2, 6), (3, 5), (5, 3), (6, 2), (3, 4), (4, 3)]
but I want to show the output like above what I first told you...
[(2,6), (3,5), (3,4)]