lst = "aaabbcddd"
ans = ""
c = 1;
for n in range(1,len(lst)):
if lst[n] == lst[n-1]:
c += 1
else:
ans += lst[n-1]+str(c)
c = 1
ans += lst[-1] + str(c)
print("입력:",lst)
print("압축:",ans)
print("출력:",len(ans))
To embed this project on your website, copy the following code and paste it into your website's HTML: