In this program, we will take a user input as a list and check whether the given list is palindrome or not with the help of the below-given steps.
List is palindrome:
Steps to solve the program
- Take a list as input.
- Create a variable and assign its value equal to the original list in reverse order.
- If both lists are equal then the list is a palindrome, else not.
#Input list
list1 = [2,4,6,6,4,2]
#Creating variable and assign
# value to it
list2 = list1[::-1]
#Printing output
if list1 == list2:
print("List is palindrome")
else:
print("List is not palindrome")
Output :
List is palindrome
Related Articles
Python Program to get a list of words which has vowels in the given string.
Python program to add 2 lists with extend method.
Python program to sort list data, with the sort and sorted method.
Python program to remove data from the list from a specific index using the pop method.
Python program to get the max, min, and sum of the list using in-built functions.
Python program to check whether a list contains a sublist.