Remove consecutive duplicates Dry Run in PYTHON

Remove consecutive duplicates is an interactive PYTHON dry run visualizer from the Recursion programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Remove consecutive duplicates Program Code

def remove_consecutive_duplicates(s):
    if len(s) <= 1:
        return s
    if s[0] == s[1]:
        return remove_consecutive_duplicates(s[1:])
    return s[0] + remove_consecutive_duplicates(s[1:])

text = "aabbccddeeff"
print(f"Original: {text}")
print(f"After: {remove_consecutive_duplicates(text)}")

View the complete Recursion programs page.

Program Console Remove consecutive duplicates Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.