I need to compare two lists in a program to see if there are matching strings. One of them is a txt document that I already imported. Thats what I did
    def compareLists(self, listA, listB):
    sameWords = list()
    for a in xrange(0,len(listA)):
        for b in xrange(0,len(listB)):
            if listA[a] == listB[b]:
                sameWords.append(listA[a])
                pass
            pass
        pass
    return sameWords
But if I run the program it doesnt show any matches although I know that there has to be one. I think its somewhere inside the if block.


list(set(listA) & set(listB))will return exactly what you want, as shown here.pass. It's useless here.passis unnecessary, it should still give you a list of all the matches found (with duplicates included).print()of the list made from the imported file. My guess is that the words it contains are ending with\n.