I have one function that calls for the function rlEncode which is supposed to take the data list and compress it so it counts how many values in a row there are and would output for example [1, 5, 3, 2, 5, 6] and so on. But when I run it just out puts the [1,5] again and again and not moving the n value over however so many spaces in the list. How would I get the n value from the function rlEncode to be used in the other function?
def rlEncode(n, z, data_list):
while data_list[n] == data_list[n+1]:
z = z + 1
n = n + 1
while data_list[n] != data_list[n+1]:
return n
return z
def unitTest( ):
c = 0
n = 0
z = 1
data_list = [1,1,1,1,1,3,3,5,5,5,5,5,5,6,8,8,1,1,1,5,5,5,5,13,14, 14]
compress_list = [ ]
while c < (len(data_list)):
n = rlEncode(n, 1, data_list)
z = rlEncode(0, z, data_list)
rlEncode(0, 1, data_list)
compress = [data_list[n], z]
c = c + 1
compress_list = compress_list + compress
print(compress_list)
n = n+1