[MACHINE LEARNING]WK1 Implement Run-length Encoding

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s