If I have understood your problem rightly, then here goes the solution for you mvcodeguide.blogspot.com/2020/08/counting-number-of-occurrences-of-each.html I have just updated my blog for your query. You can check it out!
Hi, I have discussed two ways to solve the problem One is using count () method ie an inbuilt function Second is without using count () method Kindly check it out If you need code, you can find it in the description box I have shared the link of my blog Thanks