有没有大佬给我讲讲这个为什么会输出这个结果啊

ppRYYGrrYBR2258
YrR8RrY

这是两行输入

text1,text2=list(input()),list(input())
for p in text2:
    for i in text1: 
        if i==p:
           text1.remove(p)
           text2.remove(i)

这是我写的代码,用两段for 循环遍历。我希望得出这样的结果

text1=[]
text2=['p', 'p', 'G', 'Y,  'B', '2']
text2=[‘8’ , ‘r’]
text2=['p', 'p', 'G', 'Y,  'B', '2', ‘8’ , ‘r’]

然而结果是上文这样,为啥啊

text1 = list(input())
text2 = list(input())

for p in text1:
    for i in text2: 
        if i==p:
           text1.remove(i)
           text2.remove(i)
print('text1=', text1)
print('text2=', text2)

两段for循环中的text1和text2换下位置就好了