
Compress List

A given sequence should be "compressed" in a way so, instead of two (or more) equal elements, staying one after another, there should be only one in the result sequence.
Input: List.
Output: "Compressed" List or another Iterable (tuple, iterator, generator).
Examples:
assert list(compress([5, 5, 5, 4, 5, 6, 6, 5, 5, 7, 8, 0, 0])) == [ 5, 4, 5, 6, 5, 7, 8, 0, ] assert list(compress([1, 1, 1, 1, 2, 2, 2, 1, 1, 1])) == [1, 2, 1] assert list(compress([7, 7])) == [7] assert list(compress([])) == []