the code is basically input two list and comparing each other letter-wise and if it doesn't find the letter in both words then it removes that letters but it my case once the first letter(i.e.not found in both words) is removed, it exits the loops why so
a = input()
b = input()
al = list(a)
bl = list(b)
cnt = 0
for x in al:
if x not in bl:
al.remove(x)
cnt = cnt + 1