For example, I have two lists:

```
A=['a','b','c']
B=['a','a','b','c']

```

I want my output to look like:

```
[2,1,1]

```

Here is what I tried:

```
P=np.ndarray(shape=3, dtype=int)
count=0
d=0

for i in A:
  for j in B:
    if i==j:
        count+=1
        P[d]=count
d+=1

```

But I am getting 

```
[2,3,4]

```

as output. What is going wrong?