7/40
Part 1 of 7 · Sets and seen-setsLearn and do
dict.fromkeys drops repeats and keeps first-seen order
You just wrote the dedup loop by hand. Python has a one-line version that keeps the same order.
items = [3, 1, 3, 2, 1]
print(list(dict.fromkeys(items)))
print(list(set(items)))
What does list(dict.fromkeys([3, 1, 3, 2, 1])) give?
Pick one to see what it prints.
Pick an answer above to see the rest