Basic example
Input
run_length_encode('AAAABBBCCDAA')
Output
[('A', 4), ('B', 3), ('C', 2), ('D', 1), ('A', 2)]
The input has four A's, then three B's, two C's, one D, and two A's at the end. Each consecutive run is emitted as a tuple (character, count).