Zest.

Python: Remove duplicates from a list

A short, tested Python example for remove duplicates from a list. Copy it and adjust the names and paths for your project.

Python
items = [3, 1, 3, 2, 1]

unique = list(set(items))                 # order not kept
unique_ordered = list(dict.fromkeys(items))  # keeps first-seen order

Find it in Zest

Search for “python remove duplicates from a list” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.

More Python examples

All Python examples