Counter produces a frequency table in the order that keys first appear.
from collections import Counter
counts = Counter("CABAC")
print(list(counts.items())) # [('C', 2), ('A', 2), ('B', 1)]
print(counts["Z"]) # 0The table already has one entry per distinct value. You can inspect each count once.
Implement repeated_codes(codes) using collections.Counter. Return the codes that occur at least twice, each once, in first-appearance order. The input is a list of case-sensitive strings.
repeated_codes(["X", "A", "A", "X", "B"]) # ["X", "A"]