xs = [1, 2, 2, 3]
[x for x, y in pairwise(xs) if x != y]
xs = [1, 2, 2, 2, 2, 3, 3, 3, 4, 5, 6, 6]
[x for x, y in pairwise(xs) if x != y]
How to remove adjacent duplicate elements in a list using list comprehensions?