Program Console Vignaankosh.com
Execution Panel
Console is empty.
Toggle Case of Each Character 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 toggle case of each character
text = "Hello World!"
# Method 1: Using swapcase() built-in method
toggled1 = text.swapcase()
# Method 2: Manual toggling using isupper()/islower()
toggled2 = ""
for char in text:
if char.isupper():
toggled2 = toggled2 + char.lower()
elif char.islower():
toggled2 = toggled2 + char.upper()
else:
toggled2 = toggled2 + char
# Method 3: Manual toggling using ASCII
toggled3 = ""
for char in text:
if 'a' <= char <= 'z':
toggled3 = toggled3 + chr(ord(char) - 32)
elif 'A' <= char <= 'Z':
toggled3 = toggled3 + chr(ord(char) + 32)
else:
toggled3 = toggled3 + char
print("Original:", text)
print("Built-in swapcase():", toggled1)
print("Manual (isupper/islower):", toggled2)
print("Manual (ASCII):", toggled3)