Check if String is Palindrome Dry Run in PYTHON

Check if String is Palindrome 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.

Check if String is Palindrome Program Code

# Python program to check if string is palindrome
test_strings = ["madam", "racecar", "hello", "A man, a plan, a canal: Panama"]

for s in test_strings:
    # Keep only letters and digits, and convert them to lowercase
    cleaned = ''.join(char for char in s.lower() if char.isalnum())
    
    if cleaned == cleaned[::-1]:
        print(f"'{s}' is a palindrome")
    else:
        print(f"'{s}' is NOT a palindrome")

View the complete Strings programs page.

Program Console Check if String is Palindrome Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.