Lets say I have a list of dictionaries:
[{'county': 'Lincoln County', 'state': 'SD', 'fips': '46083'}, {'county': 'Minnehaha County', 'state': 'SD', 'fips': '46099'}, {'county': 'Minnehaha County', 'state': 'SD', 'fips': '46099'},...]
In the above example, 2 of the dictionaries in this list are the same. What I want to do is check and see, by the fips
key if the value. I know that I can use something like this to check in a dictionary, and in essence, create a new list of only unique entries:
result = {}
for key,value in dictionary.items():
if value not in result.values():
result[key] = value
print result
But I am having difficulty apply this to a list of dictionaries. What am I doing wrong here?
for i in dictionary:
for key,value in dictionary[i].items():
if value not in result.values():
result[key] = value