Strings-String Compression

Hello Buddy, in Strings-String Compression as per the given sample input and output its works fine can you please look at my code and help me where is the issue in my code please

@s.v
Input:
aabbaa

Your output:
a2b2a

Correct output:
a2b2a2