I have a dictionary:
d = {'Trump': ['MAGA', 'FollowTheMoney'],
'Clinton': ['dems', 'Clinton'],
'Stein': ['FollowTheMoney', 'Atlanta']}
I want to remove the duplicate strings in the list of strings which is a value for the key.
For this example, the desired result is
update_d = {'Trump': ['MAGA'],
'Clinton': ['dems', 'Clinton'],
'Stein': ['Atlanta']}
There was a similar question asked here, but I haven't been able to modify it for my purposes.
My Attempt:
new_d = {}
for key in d:
for key2 in d:
lst = d[key]
lst2 = d[key2]
for string in lst:
for string2 in lst2:
if string not in new_d:
My problem is that I want to compare the values of all the keys and remove the duplicates. But, I don't see how this can be achieved