it = itertools.groupby([1, 2, 2, 3])
it
for key, grp in it:
    print(key)
print(grp)
it = itertools.groupby([1, 2, 2, 3])
for key, grp in it:
    pass
How to remove adjacent duplicate elements in a list using list comprehensions?