Idiom for Getting Slices of a List

Moshe Zadka moshez at math.huji.ac.il
Sat Apr 10 04:27:32 EDT 1999


Hi.

I want a clean, and relatively efficient method to do the following:
I have an array of length, n*m and I want to make it an array of 
length m, where each member is an array of length n.

Example: n=2, m=3
[0, 1, 2, 3, 4, 5] ==> [[0, 1], [2, 3], [4, 5]]

Anyone?

--
Moshe Zadka <mzadka at geocities.com>. 
QOTD: What fun to me! I'm not signing permanent.





More information about the Python-list mailing list