Test if List is Palindrome - Python Last Updated : 04 Feb, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report We are given a list we need to find that given list is a palindrome. For example a = [1, 2, 3, 2, 1] we need to check whether it is a palindrome or not so that the output should be 'True'.Using SlicingWe can check if a list is a palindrome by comparing it with its reverse using slicing ([::-1]). If the original list and its reversed version are equal list is a palindrome. Python a = [1, 2, 3, 2, 1] # Check if the list is equal to its reversed version is_pal = a == a[::-1] print(is_pal) OutputTrue Explanation:a[::-1] creates a reversed copy of the list, and a == a[::-1] checks if the original and reversed lists are identical.If they are equal is_pal is True meaning the list is a palindrome otherwise it's False.Using reversed() and list()We can check if a list is a palindrome by converting reversed iterator from reversed() into a list using list(). If original list matches this reversed list it is a palindrome. Python a = [1, 2, 3, 2, 1] # Check if the list is equal to its reversed version using reversed() and list() is_pal = a == list(reversed(a)) print(is_pal) OutputTrue Explanation:reversed(a) returns an iterator that produces elements in reverse order which is then converted to a list using list(reversed(a)).Original list is compared with its reversed version if they are equal is_pal is True indicating a palindrome.Using a for loopWe can check if a list is a palindrome using a for loop by comparing elements from the start and end moving toward center. If all corresponding pairs match list is a palindrome otherwise it is not. Python a = [1, 2, 3, 2, 1] # Compare elements from start and end moving towards the center is_pal = all(a[i] == a[-(i+1)] for i in range(len(a) // 2)) print(is_pal) OutputTrue Explanation:Generator expression iterates through the first half of the list comparing each element a[i] with its corresponding element from the end a[-(i+1)].all() ensures that if all comparisons are True is_pal is True meaning list is a palindrome; otherwise it returns False Comment More infoAdvertise with us Next Article Python program to check if number is palindrome (one-liner) M manjeet_04 Follow Improve Article Tags : Python Python Programs Python list-programs Practice Tags : python Similar Reads Python - Sort Matrix by Palindrome count Given a String Matrix of N characters, sort each row by the count of the palindromic string in it. Input : test_list = [["nitin", "meem", "geeks"], ["peep"], ["gfg", "is", "best"], ["sees", "level", "mom", "noon"]] Output : [['peep'], ['gfg', 'is', 'best'], ['nitin', 'meem', 'geeks'], ['sees', 'leve 8 min read Python Program To Check If A Singly Linked List Is Palindrome Given a singly linked list of characters, write a function that returns true if the given list is a palindrome, else false. Recommended: Please solve it on "PRACTICE" first, before moving on to the solution. METHOD 1 (Use a Stack): A simple solution is to use a stack of list nodes. This mainly invol 6 min read Python Program to Check if a String is Palindrome or Not The task of checking if a string is a palindrome in Python involves determining whether a string reads the same forward as it does backward. For example, the string "madam" is a palindrome because it is identical when reversed, whereas "hello" is not. Using two pointer techniqueThis approach involve 3 min read Python program to check if number is palindrome (one-liner) In this article, we are given a number and we have to check whether the number is palindrome or not in one-liner code. The output will be True if it's a Palindrome number otherwise it would be False. Let's discuss how to find whether a number is palindrome or not in this article. Input1: test_number 3 min read Python Program To Check If A Linked List Of Strings Forms A Palindrome Given a linked list handling string data, check to see whether data is palindrome or not? Examples: Input: a -> bc -> d -> dcb -> a -> NULL Output: True String "abcddcba" is palindrome. Input: a -> bc -> d -> ba -> NULL Output: False String "abcdba" is not palindrome. Reco 2 min read Python Program to Remove Palindromic Elements from a List Given a list, the task here is to write Python programs that can remove all the elements which have palindromic equivalent element present in the list. Examples: Input : test_list = [54, 67, 12, 45, 98, 76, 9] Output : [12, 98] Explanation : 67 has 76 as palindromic element, both are omitted. Input 2 min read Like