Implement Run-length encoding(IRE) in Python.

So, I used the array string to make the IRE. In the for loop, in range of 0 to the length of the array,

I tried to compare x[i] with x[i+1] which will compare like x[0] x[1] and x[1] x[2] and so on. However, at the end of the array there is a limited range because i+1 will eventually exceed the length of of the array. For example, if the array length is 10, there is no place to 11. So, I changed the range to 1 to the length of the array and compared x[i-1] to x[i] and now it did not show the last word of the string. So, I put ” ” at the end of the input array.

### Like this:

Like Loading...