How come I'm getting this error? I have 2 arrays a and b containing n integers. My main purpose is to remove a number from list a and b when it appears in both list. My code:
for _ in range(int(input())):
n=int(input())
a=[*map(int, input().split())]
b=[*map(int, input().split())]
i=0
j=0
for i in a:
for j in b:
if a[i]==b[j]:
a=a.pop(i)
b=b.pop(j)
m=0
i=0
for _ in range(len(a)):
if len(a[i])!=len(b[i]):
m+=2
elif a[i]!=b[i]:
m+=1
print(m)
The error that i get:
if a[i]==b[j]:
IndexError: list index out of range
a.popdoesn't returna, don't guess.iandjmay not be valid indices ofaandb.