There are some existing approaches to do what you are trying to achieve. Refer: How do you split a list into evenly sized chunks?. But what I would have done is not mentioned over there. My approach would have been using list slicing with lsit comprehension as: