Sometimes you need to remove duplicate values from a dictonary for example take a sellers.json file:
"sellers": [
{
"seller_id": "539521906",
"name": "JustPremium BV",
"domain": "justpremium.com",
"seller_type": "INTERMEDIARY",
"is_passthrough": 0
},
{
"seller_id": "540402547",
"name": "JustPremium BV",
"domain": "justpremium.com",
"seller_type": "INTERMEDIARY",
"is_passthrough": 0
},
...
]
Looping through the above would give you 2 justpremium.com
what if you wanted just one?
You can easily remove duplicate keys by dictionary comprehension, since dictionary does not allow duplicate keys, as below:
unique = { each['domain'] : each for each in sellers }.values()
Found the fix here