Considering the text line with numbers, I want to slice it into pieces with ten characters but I want to accept the fragments with less then ten if they exist.
With my script, I can obtain four complete groups, using 10 as fixed length, but the last four characters are missed.
The correct output would be:
['0123456789', '0123456789', '0123456789', '0123456789', '0123']
But I just obtain this:
['0123456789', '0123456789', '0123456789', '0123456789']
Any suggestion to fix these line in order to get the expected result?
step = 10
seq = "0123456789012345678901234567890123"
parts = []
for i in range(len(seq)/step):
sub = seq[i * step: (i + 1) * step]
parts.append(sub)
print parts