You can insert the repetition counts as you go if you are careful with resetting the counter so that the insertions in the list don't skew your end of streak detection:
L = ['a', 'a','b', 'b', 'b', 'b', 'c', 'c', 'd', 'a']
count = 0 # current number of reperitions
for i,c in enumerate(L): # go through list's indexes and items
if count and L[i-1] != c: # end of non-empty streak
L.insert(i,count) # insert count
count = 0 # and reset it
else:
count += 1 # count repetitions
L.append(count) # count for last streak
print(L)
['a', 'a', 2, 'b', 'b', 'b', 'b', 4, 'c', 'c', 2, 'd', 1, 'a', 1]
When the count is inserted, the next iteration will be on the same item (c) that caused the end of streak. Because we reset the count to zero after insertion, that item will go to the else: part and be counted as 1 (0+1) thus properly starting a new streak.
Another way to approach this is to track the index of the first item of a streak and insert the difference between indexes when detecting a change. Here too, you need to be careful with the effect of inserting into the list that you are iterating over. The index of items that cause a break in the streak will be 1 more than their original index after inserting the count:
L = ['a', 'a','b', 'b', 'b', 'b', 'c', 'c', 'd', 'a']
s = 0 # index of start of streak
for i,c in enumerate(L): # go through list's indexes and items
if L[s] != c: # end of streak
L.insert(i,i-s) # insert count
s = i+1 # track start of next streak
L.append(len(L)-s) # count for last streak
print(L)
['a', 'a', 2, 'b', 'b', 'b', 'b', 4, 'c', 'c', 2, 'd', 1, 'a', 1]