Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Straightforward approach solution in Clear category for Compress List by vnkvstnk
from typing import Iterable
def compress(items: list) -> Iterable:
if not items:
return []
compressed = [items[0],]
for item in items[1:]:
if item != compressed[-1]:
compressed.append(item)
return compressed
April 16, 2020
Comments: