[Alan McIntyre] > I have a list of items that has contiguous repetitions of values, but > the number and location of the repetitions is not important, so I just > need to strip them out. For example, if my original list is > [0,0,1,1,1,2,2,3,3,3,2,2,2,4,4,4,5], I want to end up with [0,1,2,3,2,4,5].
>>> import itertools >>> [k for k, v in itertools.groupby(lst)] [0, 1, 2, 3, 2, 4, 5] Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list