Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Sherlock Holmes
7. Find semordnilaps


Good job, here comes the last one!


OK! Write a function called find_semordnilaps(). A semordnilap is a word that spelled backwards makes a different word. E.g. 'deer' is a semordnilap because this word reversed is a new word (that actually exists) – 'reed'. The reversed word needs to differ from the original word, so 'level' is not a semordnilap.

Your function should accept a set of words as an argument and return a list of words from this set that are semondrilaps whose reversed version is also present in the set.

The function should exclude any words shorter than 3 letters.

Use the unique set of words from the Sherlock Holmes book in order to check your function. Display all semordnilaps from the file sherlock.txt.

Stuck? Here's a hint!

A shortcut to get the reversed word is: