89. Problem to get the list of palindrome strings.

In this Python list program, we will take a user input as a list and get the list of palindrome strings from the given list with the hep of the below-given steps.

List of palindrome strings:

Steps to solve the program
  1. Take a list of strings as input and create an empty string to create a list of palindrome strings.
  2. Use for loop to iterate over each string from the list
  3. During iteration check, if the string is equal to its reverse order.
  4. If yes then add that string to the empty list.
  5. Print the list to see the result.
				
					#Input lists
list1 = ["data", "python", "oko", "test", "ete"]
list2 = []

for value in list1:
    new = value[::-1]
    if new == value:
        list2.append(value)

#Printing output
print(list2)
				
			

Output :

				
					['oko', 'ete']
				
			

Related Articles

Calculate marks percentage from the given list

Flatten given nested list structure

Leave a Comment