Q:

how to generate many lists and assign values to them

I want to read a specific number of lines from a list and assign all those values to a new list.  Then I want to read the next bunch from the last_value+1 line from before for the exact same number of lines and assign those to a new list.  So far I have this:
Let's say u = [1,2,3....,9,10,11,12,13...,19,20] and I want to assign the first 10 values from u into my newly generated list1 = [] => list1 = [1,2,..9,10]
then I want the next 10 values from u to be assigned to list2 so list2 = [11,12,13..,20].  The code so far is:
nLines = 10
nrepeats = 2
j=0
i=0

while (j<nrepeats):
### Generating empty lists ###
mklist = "list" + str(j) + " = []"
### do the segmentation ###
for i, uline in enumerate(u):
    if i >= i and i < i+nLines:
       mklist.append(uline)
j=j+1

Now the problem is, that i cant append to mklist because it's a string:
AttributeError: 'str' object has no attribute 'append'

How can I assign those values within that loop?  

A:

You can use the zip function to group elements from iterables into groups of the same size.   There are actually two ways, that differ in how you way to handle cases where you can't divide the source data cleanly
u = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21]

The first way is with regular zip and discards the leftover fragment
>>>list(zip(*[iter(u)]*10))
[(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), (11, 12, 13, 14, 15, 16, 17, 18, 19, 20)]

The second way uses itertools.zip_longest and pads out the last group with some fillvalue (default None)
>>>import itertools
>>>list(itertools.zip_longest(*[iter(u)]*10, fillvalue=None))
[(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), (11, 12, 13, 14, 15, 16, 17, 18, 19, 20), (21, None, None, None, None, None, None, None, None, None)]

