The common approach to get a unique collection of items is to use a set. Sets are unordered collections of distinct objects. To create a set from any iterable, you can simply pass it to the built-in set() function. If you later need a real list again, you can similarly pass the set to the list() function.
1 2 3 4 5 |
l = [0,1,1,3,2,4,5,3,2,1,5,6,5,7] print(list(set(l))) ## Returns [0, 1, 2, 3, 4, 5, 6, 7] |