For example, string 0123456789
with input 1,2,6,1 would be:
[0,12,345678,9]
For example, string 0123456789
with input 1,2,6,1 would be:
[0,12,345678,9]
One way to do this, is with itertools.islice:
from itertools import islice
chunks = (1,2,6,1)
s = '0123456789'
assert len(s) >= sum(chunks)
it = iter(s)
result = [int(''.join(islice(it, i))) for i in chunks]
print(result)
# [0, 12, 345678, 9]
Another simplistic way of achieving the result using basic code.
a="0123456789"
inp=[1,2,6,1]
start_pos=[0] #Fix first start position
x=0
for i in inp: #Calculate start positions of slices
x=x+i
start_pos.append(x)
res=[]
for i in range(len(inp)): #Cut out slices
res.append(int(a[start_pos[i]:start_pos[i]+inp[i]]))
print (res)
[0, 12, 345678, 9]