From the course: Python Data Analysis

Unlock the full course today

Join today to access over 24,500 courses taught by industry experts.

Solution: Find palindromes

Solution: Find palindromes - Python Tutorial

From the course: Python Data Analysis

Solution: Find palindromes

- [Instructor] We need to find all palindromes of length seven or above in the dictionary. We know that two palindromes will also be anagrams, so we loop over all sets of anagrams, which we find in the anagrams_by_signature input. One way to consider all pairs of words is to use itertools.combinations. To test if the words are palindromes we can just reverse the order of one of them and check for equality. Then we make a list of the palindromes we found. Remember that we need to return sets, hence the braces. Let's try this out. Hmm, what's wrong? I see, I forgot to check the length. Perfect.

Contents