#143EasyLoops· Loops over Strings
Run-Length Encoding
Input format
`text`: a string of letters.
Output format
The encoded string.
Examples
Input: text = "aaabccc"
Output: "3a1b3c"
Three a's, one b, three c's.
Input: text = "aAaa"
Output: "1a1A2a"
Upper and lower case are different characters.
Constraints
- 0 <= len(text) <= 10^4
Study first
- #python
- #loops
- #strings
- #compression
