31 Jul Aurora Tuesday 10:30 Python Homework 21.07.27.
You have come up with the following compression technique: for each symbol, write down the number of times it appears consecutively, followed by the symbol itself. This compression technique is called run-length encoding.
Given a sequence of characters, write a program to encode them in this format: The encoding of a line will be a sequence of pairs, separated by a space, where each pair is an integer (representing the number of times the character appears consecutively) followed by a space, followed by the character.
Sample Input 1:
Output for Sample Input 1:
3 + 3 = 4 !
Explanation of Output for Sample Input
To see how the first message (on the second line of input) is encoded, notice that there are 3 + symbols, followed by 3 = symbols, followed by 4 ! symbols.
Sample Input 2:
Output for Sample Input 2:
6 7 6 . 12 T