Program Console Vignaankosh.com
Execution Panel
Console is empty.
Remove Spaces from a String is an interactive PYTHON dry run visualizer from the Strings 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.
# Python program to remove spaces from a string
text = "Remove all spaces from this string"
# Method 1: Using replace()
result1 = text.replace(" ", "")
# Method 2: Using join() with split()
result2 = "".join(text.split())
# Method 3: Using list comprehension
result3 = "".join([char for char in text if char != " "])
# Method 4: Remove all whitespace characters using regex
import re
result4 = re.sub(r'\s+', '', text)
print("Original:", text)
print("Without spaces (replace):", result1)
print("Without spaces (join):", result2)
print("Without spaces (list comp):", result3)
print("Without spaces (regex):", result4)