Why not use sets and the intersection operator (which is an operator, not a function, builtin or otherwise)? A set is a far more appropriate and efficient data structure for this problem…lists are for things that have order and contain multiple identical, potentially non-hashable elements, none of which are desirable here.
Hello, @Willien, and welcome to Python Software Foundation Discourse!
So that we are able to provide good advice, we need to know exactly what you are trying to do.
Are you trying to merge the lists, with duplicates and ordering preserved? Alternatively, are you trying to find the intersection of two lists, without duplication of the items that occur in both lists?
This does suggest that you intend to avoid duplication:
if a[i] == b[j]:
i += 1
j += 1