1 2 3 4 5 6 7 8 9 10 11 12 13 14
def unify(seq): unique = [] for x in seq: if x not in unique: unique.append(x) return unique In [1]: l = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5] In [2]: set(l) Out[2]: set([1, 2, 3, 4, 5]) In [3]: unify(l) Out[3]: [1, 2, 3, 4, 5]