Write a python function that chunks a list into smaller lists of a specified size


Topic: Write a python function that chunks a list into smaller lists of a specified size

Solution

from math import ceil
def chunk(lst, size):
  return list(
    map(lambda x: lst[x * size:x * size + size],
      list(range(ceil(len(lst) / size)))))



List all Python Programs