Re: [Tutor] split a tuple

2005-11-17 Thread János Juhász
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,

Re: [Tutor] split a tuple

2005-11-17 Thread Chris or Leslie Smith
| 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

[Tutor] split a tuple

2005-11-16 Thread János Juhász
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),