I have a list in python that looks like that: [a,b,c,d,e,f,g,h,i]
. I would like to convert this list to a list of lists (nested list). The second level of lists should contain four elements maximal. Therefore, the new list should look like that:
[
[a,b,c,d],
[e,f,g,h],
[i],
]
Is there a pythonic way to do this? I will have to do this several times so I would be pleased if anybody knows a way of doing this without using hundreds of indexes.