records = ["A", "B", "A", "C", "B"]
print("Input:", records)
print("Record count:", len(records))
The dictionary keeps insertion order, so the resulting list follows the order of the original IDs.
def unique_values(values):
return list(dict.fromkeys(values))
clean = unique_values(records)
print("Unique IDs:", clean)
print("Repeated entries:", len(records) - len(clean))
Test the expected order, an empty input, and idempotence: cleaning an already-clean list should leave it unchanged.
assert clean == ["A", "B", "C"]
assert unique_values([]) == []
assert unique_values(clean) == clean
print("All three checks passed.")
The five input entries contain three unique IDs and two repeated entries. Before applying this pattern to a real dataset, define which columns identify a record and whether repeated records should be retained, merged, or removed.