a = [1, 2, 9, 5, 1]
b = [9, 8, 7, 6, 5]
I want to count the number of duplicates between the two lists. So using the above, I want to return a count of 2 because 9 and 5 are common to both lists.
I tried something like this but it didn't quite work.
def filter_(x, y):
count = 0
for num in y:
if num in x:
count += 1
return count
returntwice), it hasO(n * m)complexit, i.e. scales pretty horribly. - user395760acontains1twice, ifbcontained1also, should the count be incremented by1or2? - John La Rooy