Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Use collections.Counter to find repeated hashable values, or group dictionary keys by value when you need to know which keys match. For lists or dictionaries stored as values, use an equality-based approach rather than passing them directly to Counter or using them as dictionary keys.
Find which values appear more than once
Count the dictionary’s values, then keep only values with a count greater than one:
from collections import Counter
d = {"a": 1, "b": 2, "c": 1, "d": 3, "e": 2}
counts = Counter(d.values())
duplicate_values = [value for value, count in counts.items() if count > 1]
print(duplicate_values) # [1, 2]
Counter is part of Python’s standard library. This produces each repeated value once; use counts itself if you also need the number of occurrences.
Find which keys share each value
To identify the original keys associated with each repeated value, build a reverse mapping from values to lists of keys, then discard groups containing only one key:
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →#1 Best Overall
from collections import defaultdict
groups = defaultdict(list)
for key, value in d.items():
groups[value].append(key)
duplicate_groups = {
value: keys for value, keys in groups.items() if len(keys) > 1
}
print(duplicate_groups) # {1: ['a', 'c'], 2: ['b', 'e']}
You can use dict.setdefault instead of defaultdict if you prefer not to import it:
groups = {}
for key, value in d.items():
groups.setdefault(value, []).append(key)
Filter groups in the same way to keep only lists with more than one key.
Rank #2
Choose an approach for the result you need
| Goal | Approach | Requirement |
|---|---|---|
| Unique repeated values | Count with Counter and filter counts greater than one |
Values must be hashable |
| Occurrence counts | Use Counter(d.values()) |
Values must be hashable |
| Keys grouped by repeated value | Collect keys into lists keyed by value | Values used as grouping keys must be hashable |
| Boolean or unique repeated values in one pass | Track values in seen and duplicates sets |
Values must be hashable |
A one-pass variant is useful when you do not need a full count table:
seen = set()
duplicates = set()
for value in d.values():
if value in seen:
duplicates.add(value)
else:
seen.add(value)
has_duplicates = bool(duplicates)
duplicates contains each repeated value once. Sets do not preserve a sorted or input-independent order, so sort the results explicitly if a particular display order matters and the values can be ordered.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallCrashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWhat if the values are lists or dictionaries?
Lists and dictionaries are unhashable, so they cannot be used directly as keys in Counter, a set, or the reverse-mapping approach above. If your values can have these types, compare them using the equality rules appropriate to your data, or normalize them into a stable hashable form. Do not convert arbitrary structures to strings as a shortcut: string representations are not a general definition of data equality.
For nested or custom objects, decide what should count as equal before choosing a comparison or normalization strategy. There is no single representation that is correct for every data shape.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Why duplicate values are allowed
Dictionary keys are unique within a dictionary, but values do not have to be. Python’s PEP 3106 explains: “The object returned by the values() method behaves like a much simpler unordered collection – it cannot be a set because duplicate values are possible.” PEP 3106
Modern Python dictionaries preserve insertion order as a language guarantee starting with Python 3.7. Iterating through d.items() therefore visits entries in that order, and replacing a value for an existing key does not change that key’s position. The duplicate values themselves are still not a set-like, unique collection.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




