Reverse a String Dry Run in PYTHON

Reverse 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.

Reverse a String Program Code

# Python program to reverse a string
original = "abcdef"

# Method 1: Using slicing (most Pythonic)
reversed1 = original[::-1]

# Method 2: Using reversed() and join()
reversed2 = ''.join(reversed(original))

# Method 3: Using a loop
reversed3 = ''
for char in original:
    reversed3 = char + reversed3

print("Original string:", original)
print("Reversed (slicing):", reversed1)
print("Reversed (reversed()):", reversed2)
print("Reversed (loop):", reversed3)

View the complete Strings programs page.

Program Console Reverse a String Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.