Python Practice › List Programs › Program 89

Palindrome strings in a list

EasyList Programs · 89 of 100

Write a Python program to get the palindrome strings from a list.

Advertisement
Input
["data", "python", "oko", "test", "ete"]
Output
['oko', 'ete']

Approach

  1. Keep words equal to their reverse.

Solution

Python
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.

More list programs

← All 100 List Programs

Leave a Comment