How to remove duplicates from list in Python?
Method 1: Using set
>>> _list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> unique = list(set(_list)) >>> print(unique) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Method 2: Using dict from keys
>>> _list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> unique = list(dict.fromkeys(_list)) >>> print(unique) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]