How do you remove duplicates from a list while keeping order?
Model answer
list(dict.fromkeys(items)) works because dictionaries keep insertion order and keys are unique. set(items) removes duplicates but does not keep the original order.
Learn this topic
Dictionaries, Tuples and Sets in Python in the course Python for Beginners: Learn to Code with Real Projects.
Sign in to add your own answer.