pyassistant

Remove consecutive duplicate characters

Given a string, return a new string where every run of consecutive identical characters is replaced by a single instance of that character. Preserve the original order of characters that remain. Examples: - "aaabbcaaa" -> "abca" - "hello" -> "helo" Write a function that performs this compression and returns the resulting string.

Example:

Input:
('aaabbcaaa',)
Output:
'abca'

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.