I have a problem decoding.
First the string '44444' get encoded to '54'. (5 times 4)
Now when I want to decode '54' its empty.
(It does function with letters)
The algorithm decodes the string '4a3b2c' to 'aaaabbbcc'.
Now when I want to decode '4a54' it just gives 'aaaa' but the right decoding is 'aaaa44444'. How can I decode this?
Here is the code:
def decode_RLE(x):
decode = ''
count = ''
for i in x:
if i.isdigit():
#append to count
count += i
else i:
decode += i * int(count)
count = ''
return decode