0

is there any fast Python dict checker for same values. I have tried with this code but I'm stuck with it.

uniq= [{'id': 1, 'name': u'Mobil'}, {'id': 2, 'name': u'Mobil'}, 
    {'id': 1, 'name': u'Ikea'}, {'id': 2, 'name': u'Ikea'}]
result={}
for dict in uniq:
    for key, value in dict.items():
        result.setdefault(key,value)
print result

And the output in new dict would be like:

result = [{'id': 1, 'name': u'Mobil'},{'id': 2, 'name': u'Ikea'}]

With this code i get only one reslut in result, and that is {'id': 1, 'name': u'Mobil'}

Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176
Marin
  • 1,098
  • 14
  • 33

0 Answers0