For example if I have 2 lists:
list1 = [2,3]
list2 = [a,b,c,d,e]
The new list should become
newlist = [[a,b], [c,d,e]]
So the values of the first list make up the amount of values inside the nested lists.
For example if I have 2 lists:
list1 = [2,3]
list2 = [a,b,c,d,e]
The new list should become
newlist = [[a,b], [c,d,e]]
So the values of the first list make up the amount of values inside the nested lists.
What about this?
Code:
list1 = [2,3]
list2 = ['a','b','c','d','e']
rv = []
start = 0
for i in list1:
rv.append(list2[start:start+i])
start += i
Output:
>>> rv
[['a', 'b'], ['c', 'd', 'e']]