# [Tutor] how to delete some quasi-duplicated keys

lina lina.lastname at gmail.com
Fri Nov 25 10:34:25 CET 2011

```#!/usr/bin/python3

dehydrons={}
pairs={}
#frozen set way pairs
fs_pairs={}
occurence={}
total=0
dictionary={}
candidate_dehydron={}

if __name__=="__main__":

with open("dehydron_refined_data_18.txt","r") as f:
parts=line.split()
#pair=set((parts[0],parts[1]))
if (parts[0],parts[1]) not in dehydrons.keys():
dehydrons[(parts[0],parts[1])]=parts[2]
occurence[(parts[0],parts[1])]=1
#pair=frozenset(('parts[0]','parts[1]'))
#pairs[pair]=pairs.get(pair,0)+parts[2]
else:
occurence[(parts[0],parts[1])]+=1
#for k, v in dehydrons.items():
#print(k,v)

for k, v in occurence.items():
if v>=25:
#print(v,k)
candidate_dehydron[k]=v
#print("{:.2f}".format(v/2768*100),k)
total+=v
print(total)

for k, v in candidate_dehydron.items():
pairs[k] = v

'''for key in pairs.keys():
if key[::-1] in pairs:
pairs[key] += pairs[key[::-1]]
del pairs[key[::-1]]
print(pairs)'''

#for k, v in pairs.items():
#print(v,k)

I attached the not working code,  Thanks for any advice,

best regards,
```