Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

make lists for each 2 items in a list

>>> theList = list(range(10))
>>> N = 3
>>> subList = [theList[n:n+N] for n in range(0, len(theList), N)]
>>> subList
[[0, 1, 2], [3, 4, 5], [6, 7, 8], [9]]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #lists #items #list
ADD COMMENT
Topic
Name
1+2 =