Hi Chris,
Thanks your response.
I have just found another way.
>>> import math
>>> l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5)
>>> n = 4
>>> extended = l + ('default',)*int(n - math.fmod(len(l),n))
>>> [extended[i:i+n] for i in range(0,len(extended),n)]
[(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4,
| Hi,
|
| I couldn't get idea how to make the next thing
|
n=4 #split into so long parts
l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5) #this is the tuple to split
[l[i:i+n] for i in range(0,len(l),n)]
| [(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4, 5)]
|
| But I have to make it like thi
Hi,
I couldn't get idea how to make the next thing
>>> n=4 #split into so long parts
>>> l = (1,2,3,4,5,1,2,3,4,5,1,2,3,4,5) #this is the tuple to split
>>> [l[i:i+n] for i in range(0,len(l),n)]
[(1, 2, 3, 4), (5, 1, 2, 3), (4, 5, 1, 2), (3, 4, 5)]
But I have to make it like this
[(1, 2, 3, 4),