Hello everybody,
I managed to convert a string of a given lenght consisting of 2 numbers only (0 and 1) into a list of positions of the number '1', (see example below).
Note: The string size is always going to be a multiple of 4!
Example for string lenght equals 8:
>>> string = "01010100"
>>> [i for i in range(len(strin g)) if string.startswi th('1', i)]
[1, 3, 5]
Problem:
I would like to "back calculate" the original string "01010100" from the list of positions [1, 3, 5]
Means: convert the list [1, 3, 5] back to a string 01010100
Your help is appreciated.
I managed to convert a string of a given lenght consisting of 2 numbers only (0 and 1) into a list of positions of the number '1', (see example below).
Note: The string size is always going to be a multiple of 4!
Example for string lenght equals 8:
>>> string = "01010100"
>>> [i for i in range(len(strin g)) if string.startswi th('1', i)]
[1, 3, 5]
Problem:
I would like to "back calculate" the original string "01010100" from the list of positions [1, 3, 5]
Means: convert the list [1, 3, 5] back to a string 01010100
Your help is appreciated.
Comment