# This finds teh reversible words in the
# dictionary file words25K.txt

def reverse(s):
    if len(s) <= 1:
        return s
    else:
        return reverse(s[1:])+s[0]
    
def main():
    F = open( "words25K.txt", "r")
    words = []
    for line in F:
        word = line.strip()
        words.append(word)

    count = 0
    for word in words:
        rev = reverse(word)
        if rev in words and rev >= word:
            print(word, rev)
            count = count + 1
    print( "I found %d reversible words."%count)

main()
    
