I know how to split a list into even groups, but I\'m having trouble splitting it into uneven groups.
Essentially here is what I have: some list, let\'s call it
This solution keeps track of how many items you've written. It will crash if the sum of the numbers in the second_list is longer than mylist
total = 0
listChunks = []
for j in range(len(second_list)):
chunk_mylist = mylist[total:total+second_list[j]]
listChunks.append(chunk_mylist)
total += second_list[j]
After running this, listChunks is a list containing sublists with the lengths found in second_list.