Write a programExercise 1/4Basic10 XP

Compressing text

Task

The program reads a word and compresses it: each run of identical characters becomes the character followed by the length of the run. The word aaabccdddd becomes a3b1c2d4.

Mind the edge cases: the word may have a single character, or be empty - then the program prints an empty line.

Examples

  • Input

    aaabccdddd

    Expected output

    a3b1c2d4

After you submit, 5 hidden tests will also check your solution: an empty word, one character, no repeats, more than 9 repeats, a character comes back later.

Python starts the first time you run code.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Input (stdin)

Each line = one call to input().

Output

Hints

Try it yourself first. Each hint reveals a little more - and lowers the reward a little.

Signed out, hints are free - but no XP is awarded either.

Solution

The solution unlocks after the last hint.