← Back to challenges

Stretched Words

PythonHardstringsformattingloops

Instructions

Write a function that takes a string, and returns a new string with any duplicate consecutive letters removed.

Examples

unstretch("ppoeemm") ➞ "poem"

unstretch("wiiiinnnnd") ➞ "wind"

unstretch("ttiiitllleeee") ➞ "title"

unstretch("cccccaaarrrbbonnnnn") ➞ "carbon"

Notes

Final strings won't include words with double letters (e.g. "passing", "lottery").

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: A Simple Task