In input we getting string like
asdfssgAAatG
and output must be a compressed string with letter count. For example input
aabggtttf
must give
a2b1g2t3f1
so letter and how many times it repeated in row in output. The input
abc
must give
a1b1c1
in output. So i wrote some code for it:
a=str(input())+' '
count=1
b=1
r=''
for i in range (a.count('')-2):
if a[i]==a[i+1]:
b+=1
else:
count=b
b=1
r=r+a[i]+str(count)
if a!=' ':
print(result=r[0:-1]+str(count))
For me code works flawless and when i put test input it give correct answer. But on site where i need to insert that code 'steptic.org' some of automated tests give error, and i cant complete this task. So here the question: what wrong with this code and what input can give error here? Maybe is here some simplier way to perform this task on Python? P.S Sry for my bad english =) P.S Capitalization matter, test content i cant see, i tryed some test data - all worked.. , seems i just cant think out data what gives incorrect answer.