run_length_encode(s) that compresses s by replacing every run of identical consecutive characters with the character followed by its run length, e.g. "aaabbc" becomes "a3b2c1". Every character gets a count, even runs of length 1.s = 'aaabbc'
'a3b2c1'
'aaa' -> a3, 'bb' -> b2, 'c' -> c1.
s = 'abc'
'a1b1c1'
Every character is its own run of length 1.
Walk the string tracking a running count; when the next character differs from the current one, flush char+count to the result.
Don't forget to flush the final run after the loop ends.