I'm building a program in Python 3 that needs to go through two lists and count how many times the elements of the first list appear in the second. However, even if I plug in two lists that are hard-coded to have common elements, Python says the list doesn't have any common elements.
Here's a minimal, runnable version of my program:
strings = ["I sell","seashells","by the","seashore"]
ngramSet = ["by the"]
for ngram in ngramSet:
    print("Ngram: \"" + str(ngram) + "\"")
    # Should return "by the" twice where it appears twice.
    occurrences = [element for element in strings if element is ngram]
    print("Occurrences: " + str(occurrences))
    count = len(occurrences)
    print("Number of times N-gram appears in string" + str(count))
Output:
Ngram: "by the"
Occurrences: []
Number of times N-gram appears in string0
 
     
     
     
     
    