What is the most efficient way to find consecutively repeating strings in a Python list?
For example, suppose I have the list
["a", "a", "b", "c", "b","b","b"]
. I want an output of something like: ["group of 2 a's found at index 0, group of 3 b's found at index 4']
.
Is there a built in function to accomplish this task? I did find numpy.bincount
, but that seems to only work on numeric values.
Thanks in advance for the help.