Split A Python List Based Off A Number Of Items
This function takes a list and a number of items to group. It returns a list of lists where each sub-list contains the requested number of items.
=
=
return
=
=
Output:
[['a', 'b'], ['c', 'd'], ['e', 'f'], ['g']]
Here's a basic way to do it with just a single split of the first items based on the requested number with the rest of the items going into the second list.
return
=
=
Output:
[['a', 'b'], ['c', 'd', 'e', 'f', 'g']]
-- end of line --