Run-length encoding
Write encode(text) that compresses runs of repeated characters into the character followed by its count, and decode(encoded) that reverses it. Assume the input contains no digits.
Examples
encode("aaabccdddd") → "a3b1c2d4"
decode("a3b1c2d4") → "aaabccdddd"Exercise
4 checksRun-length encoding
def encode(text):
...
def decode(encoded):
...
print(encode("aaabccdddd"))
print(decode("a3b1c2d4"))
Press Run to try your code, then Check answer to grade it.