# How can I get the count of how many times a string appears in my list? [closed]

I have a list of strings, like so:

{"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss", "kk mm"}


I know WordCounts will return the numbers of every single word, but I want to the word group numbers, i.e., "aa bb" 3 times, and "cc dd" 2 times. How can I do this?

## closed as off-topic by MarcoB, Carl Lange, Henrik Schumacher, Öskå, marchMar 8 at 17:26

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, Carl Lange, Henrik Schumacher, Öskå, march
If this question can be reworded to fit the rules in the help center, please edit the question.

You can try Tally

lst = {"aa bb", "cc dd", "aa bb", "aa bb", "cc dd", "ww ss", "ss ss",   "kk mm"};
Tally[lst]


Edit by m_goldberg

As J.M. says in his comment below, Counts will give the same information as an association.

Counts[data]


<|"aa bb" -> 3, "cc dd" -> 2, "ww ss" -> 1, "ss ss" -> 1, "kk mm" -> 1|>

This is equivalent to

Rule @@@ Tally[data] // Association

• Counts[] should also work. – J. M. is away Mar 4 at 5:48