Simple example
Input
remove_consecutive_duplicates([1, 1, 2, 2, 1])
Output
[1, 2, 1]
Consecutive runs of 1 and 2 are collapsed, but the later 1 is kept because it's not consecutive with the earlier 1.
Full lesson preview
Return a new list with consecutive duplicate values collapsed to a single occurrence.
Problem statement
Task
Examples
Input
remove_consecutive_duplicates([1, 1, 2, 2, 1])
Output
[1, 2, 1]
Consecutive runs of 1 and 2 are collapsed, but the later 1 is kept because it's not consecutive with the earlier 1.
Input format
Output format
Constraints
Samples
Input
remove_consecutive_duplicates(['a', 'a', 'b', 'a'])
Output
['a', 'b', 'a']
Only consecutive 'a' at the start are collapsed; the later 'a' remains.