Simple List division problem

marcstuart marc.stuart.risney at gmail.com
Sat Jan 12 14:13:22 EST 2008


I have gotten a little further, but not in the order of the original
list

def divide_list(lst, n):
    return [lst[i::n] for i in range(n)]

x = [1,2,3,4,5,6,7,8,9,10]
y = 3
z =  divide_list(x,y)

print z[0]
print z[1]
print z[2]


this prints:

[1, 4, 7, 10]
[2, 5, 8]
[3, 6, 9]



closer, but I would like to maintain the original order of the list.



More information about the Python-list mailing list