Q:

Deleting common elements between 2 lists and printing the two arrays

I am deleting the common elements between 2 sorted arrays in both the arrays and returning the arrays with the help of 2 pointers.
But I can't figure out the condition in while loop: what should be the condition?
here is my code:
a=[4,8,9,10,12,14,16]
b=[2,8,10,12,13]
i=0
j=0
while():
     if (a[i]==b[j]):
      a.pop(i)
      b.pop(j)
    elif(a[i] > b[j]):
      j=j+1
    else:
      i=i+1
print(a)
print(b)

A:

Your while loop should be running until variable i is less than len(a) and variable j is less than len(b).
Since you have missed some part of your list a, I tried to run your code with 13 as the last element.
NOTE:
The code will only work if both lists are sorted.
a=[4,8,9,10,13]
b=[2,8,10,12,13]
j=0
i = 0
while i < len(a) and j < len(b):
        if (a[i]==b[j]):
                a.pop(i)
                b.pop(j)
        elif(a[i] > b[j]):
                j=j+1
        else:
                i=i+1
print(a)
print(b)

Output:
[4, 9]
[2, 12]

You can also try the code below. It is more readable and doesn't require the lists to be sorted. It uses list comprehension.
a1 = [x for x in a if x not in b]
b1 = [x for x in b if x not in a]

