Palindromes are words, numbers or phrases that read the same from left to right and from right to left. Examples of palindromic words in English are eye, gig, kayak, reviver, level, rotator and redivider. The term semordnilap (palindromes spelled from right to left) is used for words that deliver a different word when spelled from right to left. According to the linguist Dmitri A. Borgmann the term was introduced by Martin Gardner in Oddities and Curiosities of Words and Literature.

Assignment

When determining whether a given word occurs in the given set of words, no distinction should be made between uppercase and lowercase letters.

Example

In the following example session we assume that the file words.txt1 is in the current directory.

>>> words = dictionary('words.txt')

>>> len(words)
321115

>>> semordnilap('dream', words)
True
>>> semordnilap('rule', words)
True
>>> semordnilap('fever', words)
True
>>> semordnilap('rocks', words)
True
>>> semordnilap('lever', words)
False