I\'m trying to remove duplicate values in my dict but its not working:
samples_antibiotics_with_duplicates = {\'S00541-09\': [\'Streptomycin\', \'Sulfamethox
The below dict comprehension will create a new dict from the original one without any duplicate values:
samples_antibiotics = {k: list(set(v)) for k, v in samples_antibiotics_with_duplicates.items()}
The set
version of a list (or any container) does not contain any duplicates since sets do not allow any (that is why they require hashable items as do dicts).
As @CoryKramer says in the comments, the solution given here will not (generally speaking) preserve the order of the items in the values-list. If that is important to you, you would have to go with something else.