← How-To Guides How-To How to remove duplicates from a list Use list(dict.fromkeys(lst)) to preserve order, or list(set(lst)) if order does not matter. Preserve order dict.fromkeys keeps first occurrence order. lst = [1,2,2,3,1] unique = list(dict.fromkeys(lst)) # [1,2,3]