I have a python list where elements can repeat.
>>> a = [1,2,2,3,3,4,5,6]
I want to get the first n unique elements from
n
Using set with sorted+ key
set
sorted+ key
sorted(set(a), key=list(a).index)[:5] Out[136]: [1, 2, 3, 4, 5]