Remove duplicate characters from string using set Dry Run in PYTHON

Remove duplicate characters from string using set is an interactive PYTHON dry run visualizer from the Sets 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 duplicate characters from string using set Program Code

# Remove duplicate characters from string
text = "programming"
print("Original:", text)

# Method 1: Using set (order not preserved)
unique_chars = ''.join(set(text))
print(f"Using set: {unique_chars}")

# Method 2: Using dict.fromkeys() (preserves order)
unique_ordered = ''.join(dict.fromkeys(text))
print(f"Preserving order: {unique_ordered}")

# Method 3: Manual loop (preserves order)
result = ""
for char in text:
    if char not in result:
        result += char
print(f"Manual loop: {result}")

View the complete Sets programs page.

Program Console Remove duplicate characters from string using set Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.