Check whether list is palindrome Dry Run in PYTHON

Check whether list is palindrome is an interactive PYTHON dry run visualizer from the Lists 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 whether list is palindrome Program Code

# Check if list reads same forward and backward
list1 = [1, 2, 3, 2, 1]
list2 = [1, 2, 3, 4, 5]

def is_palindrome(lst):
    # Method 1: Compare with reverse
    return lst == lst[::-1]

print(f"{list1} is palindrome: {is_palindrome(list1)}")
print(f"{list2} is palindrome: {is_palindrome(list2)}")

# Method 2: Two-pointer approach
def is_palindrome_two_pointer(lst):
    left, right = 0, len(lst) - 1
    while left < right:
        if lst[left] != lst[right]:
            return False
        left += 1
        right -= 1
    return True

print(f"\nTwo-pointer: {list1} → {is_palindrome_two_pointer(list1)}")

View the complete Lists programs page.

Program Console Check whether list is palindrome Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.