I want to eliminate repeated elements from list and return number of time element is repeated

Even though i'm using list but in json format Counter throws error

if dict inside list cannot be used here please let me know any fast alternative (because len(all\_response) would be in 6 digit )

here is my code:

```
from collections import Counter
all_response = [
          {
           "stock_id": 315,
            "product_id": 315
        },
        {
           "stock_id": 315,
            "product_id": 315
        },
        {
            "stock_id": 1,
            "product_id": 1
        },
        {
            "stock_id": 2,
            "product_id": 2
        },
        {
            "stock_id": 2,
            "product_id": 2
        },
        {
            "stock_id": 6,
            "product_id": 6
        }]
stock_ids = []
d = Counter(all_response)
for i in all_response:
    if i['stock_id'] not in stock_ids:
        stock_ids.append({'stock_id':i['stock_id']})
        stock_ids.append({'product_count': d[i['stock_id']]})
print(stock_ids)

```

Expected Output:

```
[
          {
           "stock_id": 315,
            "product_count": 2
        },{
            "stock_id": 1,
            "product_count": 1
        },
        {
            "stock_id": 2,
            "product_count": 2
        },
        {
            "stock_id": 6,
            "product_count": 1
        }]

```