4/28
Part 1 of 6 · The screen as a setLearn and do

Keep the first copy of each title in a row

The second rule lives inside one row: no title twice. Rows come from different rankers, and a row can list one title twice, a show in two genres for example. The dedup keeps the first copy, because the row's order is its ranking, and the first copy is where the ranker wanted it.

dict.fromkeys does exactly that. A dict keeps its keys in the order they first went in, and a key that comes again changes nothing:

row = ["C", "A", "C", "B", "A"]
print(list(dict.fromkeys(row)))
print(sorted(set(row)))
Predict

What does list(dict.fromkeys(['C', 'A', 'C', 'B', 'A'])) give?

Pick one to see what it prints.
Pick an answer above to see the rest