pyassistant

Remove Consecutive Duplicates from a List of Strings

Write a function that takes a list of strings and returns a new list where any consecutive duplicate elements are collapsed to a single occurrence. Only adjacent equal strings should be removed; non-adjacent duplicates should be kept. Comparison is case-sensitive.

Example:

Input:
(['a', 'a', 'b', 'b', 'a', 'c', 'c', 'c'],)
Output:
['a', 'b', 'a', 'c']

Make sure you return your solution, don't print!

AI

Bot

Trying to solve my challenge? Ask if you must, or press the purple button so I can analyze your code.