압축전 = input("압축하려는 문자열: ")
압축후 = ""
글자수 = 1
이전문자 = 압축전[0]
for 현재문자 in 압축전 [1:]:
if 현재문자 == 이전문자:
글자수 = 글자수 + 1
else:
압축후 = 압축후 + 이전문자 + str(글자수)
글자수 = 1
이전문자 = 현재문자
압축후 = 압축후 + 이전문자 +str(글자수)
print(압축후)
해제전 = input("압축 해제할 문자열: ")
해제후 = ""
i = 0
while i < len(해제전):
문자 = 해제전[i]
글자수 = int(해제전[i+1])
j = 0
while j < 글자수:
해제후 = 해제후 + 문자
j = j + 1
i = i + 2
print(해제후)
To embed this project on your website, copy the following code and paste it into your website's HTML: