Python Practice › List Programs › Program 89
Palindrome strings in a list
Write a Python program to get the palindrome strings from a list.
Input
["data", "python", "oko", "test", "ete"]
Output
['oko', 'ete']
Approach
- Keep words equal to their reverse.
Solution
words = ["data", "python", "oko", "test", "ete"]print([w for w in words if w == w[::-1]])Output
['oko', 'ete']
Learn the concept
New to this topic? Read the lesson, then come back.