compare pairs of words with python