Try this dict comprehension:
new_dct = {k: v for k, v in dct.items() if list(dct.values()).count(v) <= 1}
This won't delete from your original dictionary, but will generate a new dictionary with only the keys and values where the value is not duplicated in your original dictionary.*
*: Note that in Python 3.x the values()
method of dict
objects returns a view object, while in Python 2.x it returns a normal list
object. Hence the need to call list()
on it here in order to use the count()
list method, since OP is using Python 3.x. If you are using Python 2.x, you can simply remove the list()
call, and call count()
on dct.values()
directly.