Hi,
I have a dictionary which looks something like this:

elem = {"co":[1,2,3],"cp":[3,2,1],"pp":[5,6,7],"cl":[1,2,3],"qw":[6,7,8],"qa":[8,7,6]}

what Im trying to do is find all keys in the list that have the same value and delete those (except one); thereby removing all redundant keys so that the above dict will look like this:

elem = {"co":[1,2,3],"pp":[5,6,7],"qa":[8,7,6]}

my code so far looks like this:

for out1 in elem.keys():
   for out2 in elem.keys():
       if out1 != out2:
           elem[out1].sort()
           elem[out2].sort()
           if elem[out1] == elem[out2]:
               del elem[out1]

This returns in a KeyError exception when sorting. What am I missing here?
Thanks
Astan
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to