I need to count non-unique sequences going sequentially. For example: "aabcccjaaa" is "21313". But my code do not count the last string. In checks, it goes to the last "else" and must add the last "a" as a unit to the result. What could be the problem? And maybe someone knows a solution instead of mine using standard libraries?
a = "assdddfghttyuuujssa"
b = ''
c = 1
d = []
for item in a:
if item == b:
c += 1
elif b == '':
c = 1
else:
d.append(c)
c = 1
b = item
print(d)
I tried to add output of unique words on each iteration of the loop, however it still doesn't show why the last "append" doesn't add "1" to the result.