Here's a generator that yields evenly-sized chunks:

def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    for i in range(0, len(lst), n):
        yield lst[i:i + n]
import pprint
pprint.pprint(list(chunks(range(10, 75), 10)))
[[10, 11, 12, 13, 14, 15, 16, 17, 18, 19],
 [20, 21, 22, 23, 24, 25, 26, 27, 28, 29],
 [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
 [40, 41, 42, 43, 44, 45, 46, 47, 48, 49],
 [50, 51, 52, 53, 54, 55, 56, 57, 58, 59],
 [60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
 [70, 71, 72, 73, 74]]

For Python 2, using xrange instead of range:

def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    for i in xrange(0, len(lst), n):
        yield lst[i:i + n]

Below is a list comprehension one-liner. The method above is preferable, though, since using named functions makes code easier to understand. For Python 3:

[lst[i:i + n] for i in range(0, len(lst), n)]

For Python 2:

[lst[i:i + n] for i in xrange(0, len(lst), n)]
Answer from Ned Batchelder on Stack Overflow
๐ŸŒ
Real Python
realpython.com โ€บ how-to-split-a-python-list-into-chunks
How to Split a Python List or Iterable Into Chunks โ€“ Real Python
July 23, 2026 - You can split a list into chunks without using a library by implementing a custom loop with slicing. You handle infinite data streams in Python by leveraging itertools.batched() for lazy evaluation.
Discussions

Split list into smaller lists
There are likely some helper functions that make this possible in a line or two but it's almost 4am here so I'm drawing a blank. Doing it with a dumb loop is pretty simple though: def splitList(input, delim): # We'll return a list of lists outLists = [] # Read each item, if it's not the delimiter (e.g. "x") # add it to the current list. If it is the delimiter, # add the current list to the output and empty it. currentList = [] for item in input: if item == delim: if len(currentList) > 0: outLists.append(currentList) currentList = [] else: currentList.append(item) # If we get to the end and there are leftovers in the current # list, add them as well if len(currentList) > 0: outLists.append(currentList) return outLists You could call this like: splitList(your_list_above, "x") Might be some edge cases I'm not thinking of, maybe multiple delimiters in a row or something (?), didn't really test this but it should get you started Edit: Made a stupid mistake above but not going to fix it, should never use "input" as a variable, so call it something else, like "inputList" instead More on reddit.com
๐ŸŒ r/learnpython
12
1
January 6, 2021
Splitting dict into n equal chunks?
Even though this might be better solves using a non-python solution as u/K900_ suggested, I'm still interested in OP's question: how do you split a dict like that? More on reddit.com
๐ŸŒ r/learnpython
9
5
January 17, 2018
๐ŸŒ
Python Engineer
python-engineer.com โ€บ posts โ€บ split_list_in_chunks
How to split a List into equally sized chunks in Python - Python Engineer
May 29, 2023 - from itertools import batched chunks = list(batched(my_list, 3)) # [(0, 1, 2), (3, 4, 5), (6, 7, 8), (9,)]
๐ŸŒ
DEV Community
dev.to โ€บ askyt โ€บ break-a-list-into-chunks-of-size-n-in-python-1bj0
Break a list into chunks of size N in Python - DEV Community
January 4, 2025 - The islice function can split the iterable into fixed-size chunks. ... from itertools import islice def chunk_with_itertools(data, size): data_iter = iter(data) while chunk := list(islice(data_iter, size)): yield chunk letters = "abcdefghijk" ...
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to split a list into chunks in python
How to Split a List Into Chunks in Python
January 25, 2026 - from itertools import islice def chunk_iterable(iterable, chunk_size): """Split any iterable into chunks. Works with iterators that do not support indexing. """ iterator = iter(iterable) while True: chunk = list(islice(iterator, chunk_size)) if not chunk: break yield chunk # Works with generators and iterators def number_generator(): for i in range(10): yield i for chunk in chunk_iterable(number_generator(), 3): print(chunk) # [0, 1, 2] # [3, 4, 5] # [6, 7, 8] # [9] Python 3.12 introduced itertools.batched specifically for this purpose.
๐ŸŒ
ItsMyCode
itsmycode.com โ€บ python-split-list-into-chunks
Python Split list into chunks - ItsMyCode
October 15, 2024 - We can leverage the itertools module to split a list into chunks. The zip_longest() function returns a generator that must be iterated using for loop. Itโ€™s a straightforward implementation and returns a list of tuples, as shown below.
๐ŸŒ
w3resource
w3resource.com โ€บ python-exercises โ€บ itertools โ€บ python-itertools-exercise-40.php
Python: Split a given list into specified sized chunks using itertools module - w3resource
July 12, 2025 - from itertools import islice def split_list(lst, n): lst = iter(lst) result = iter(lambda: tuple(islice(lst, n)), ()) return list(result) nums = [12,45,23,67,78,90,45,32,100,76,38,62,73,29,83] print("Original list:") print(nums) n = 3 print("\nSplit the said list into equal size",n) print(split_list(nums,n)) n = 4 print("\nSplit the said list into equal size",n) print(split_list(nums,n)) n = 5 print("\nSplit the said list into equal size",n) print(split_list(nums,n))
Find elsewhere
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ break-list-chunks-size-n-python
Break a List into Chunks of Size N in Python - GeeksforGeeks
October 28, 2025 - The zip_longest() function from the itertools module can be used to break a list into evenly sized chunks by grouping elements together in tuples of size n.
๐ŸŒ
Reddit
reddit.com โ€บ r/python โ€บ how to split a python list or iterable into chunks โ€“ real python
r/Python on Reddit: How to Split a Python List or Iterable Into Chunks โ€“ Real Python
February 9, 2023 - This tutorial provides an overview of how to split a Python list into chunks. You'll learn several ways of breaking a list into smaller pieces using the standard library, third-party libraries, and custom code. You'll also split multidimensional data to synthesize an image with parallel processing. Archived post. New comments cannot be posted and votes cannot be cast. Share ... While you have nothing in the standardlib, you have an example function for this in the itertools documentation :
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python โ€บ python split list into chunks
How to Split List Into Chunks in Python | Delft Stack
February 2, 2024 - A Python list can be divided into different chunks of equal sizes. It can be done by using user-defined functions, list comprehension, itertools, lambda, lambda and islice, and NumPy methods.
๐ŸŒ
DEV Community
dev.to โ€บ itsmycode โ€บ python-split-list-into-chunks-332a
Python Split list into chunks - DEV Community
December 8, 2021 - We can leverage the itertools module to split a list into chunks. The zip_longest() function returns a generator that must be iterated using for loop. Itโ€™s a straightforward implementation and returns a list of tuples, as shown below.
๐ŸŒ
Newtum
blog.newtum.com โ€บ split-a-list-into-evenly-sized-chunks-in-python-using-itertool
Split a List Into Evenly Sized Chunks in Python Using itertool - Newtum
April 24, 2024 - Can I adjust the chunk size according to my requirements? Yes, you can adjust the chunk size by providing a different value for the arr_size argument when calling the chunk function. This allows you to split the list into chunks of any desired size.
๐ŸŒ
Educative
educative.io โ€บ answers โ€บ how-to-split-a-python-list-into-evenly-sized-chunks
How to split a Python list into evenly sized chunks
Line 3: We use list comprehension to chunk lst into chunks of size, chk_size. Lines 5โ€“6: We print the original and the chunked list. We can chunk the list into the given sizes using the islice method of the itertools module.
๐ŸŒ
i2tutorials
i2tutorials.com โ€บ home โ€บ blogs โ€บ splitting a list into equal chunks in python
Splitting a List into equal Chunks in Python | i2tutorials
January 2, 2021 - #splitting list into even chunks using lambda and islice my_list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve'] from itertools import islice def group_elements(it, size): it = iter(it) return iter(lambda: tuple(islice(it, size)), ()) for i in group_elements( my_list , 3): print(i)
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-split-list
How to Split Lists in Python: Basic and Advanced Methods | DataCamp
June 21, 2024 - The above code uses Python split list into n chunks of size three to return a new list with chunk lists of 3 values. Python split list using itertools uses the Python module to transform data through iteration.
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ how-to-split-a-list-into-even-chunks-in-python
How to Split a List into Even Chunks in Python
September 19, 2021 - The list has been split into equal chunks of 7 elements each. Python has utilities to simplify this process. We can use the zip_longest function from itertools to simplify the previous function.
๐ŸŒ
Sopython
sopython.com โ€บ canon โ€บ 14 โ€บ splitting-a-list-into-even-chunks
Splitting a list into even chunks. - sopython
chunk ยท split ยท list ยท Using the grouper recipe from the itertools documentation: >>> from itertools import zip_longest # Use izip_longest for Python 2.x >>> def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return zip_longest(*args, fillvalue=fillvalue) >>> list(grouper(a, 3)) [(1, 2, 3), (4, 5, 6), (7, None, None)] Another approach to exclude worrying about fill values (although itโ€™s slightly less efficient) is to build a list of the certain chunk size and yield, eg: from itertools import islice def grouper(iterable, n): yield from iter(lambda it=iter(iterable): list(islice(it, n)), []) # Or in Python 2.7, where `yield from` doesn't exist yet, use: # for chunk in iter(lambda it=iter(iterable): list(islice(it, n)), []): # yield chunk ยท
๐ŸŒ
FavTutor
favtutor.com โ€บ blogs โ€บ partition-list-python
Partition a List in Python | Split Python List | FavTutor
January 26, 2022 - Now let us understand, how we can divide a list into smaller chunks of a given size using this method. In this approach, we create a generator method that yields a slice or chunk of the original list.
๐ŸŒ
pythontutorials
pythontutorials.net โ€บ blog โ€บ how-to-split-a-list-into-chunks-determined-by-a-separator
How to Split a List into Chunks by Separator in Python: Efficient Step-by-Step Guide โ€” pythontutorials.net
We then filter out the key=True groups and convert the remaining groups to lists to form our chunks. from itertools import groupby def split_list_by_sep_groupby(lst, sep): # Group elements by whether they are the separator groups = groupby(lst, ...
๐ŸŒ
Medium
medium.com โ€บ towardsdev โ€บ split-a-python-list-or-iterable-into-chunks-3f7171e6438d
Split a Python List or Iterable Into Chunks | by Py-Core Python Programming | Towards Dev
May 8, 2025 - Whether you are preprocessing data for machine learning (ML), feeding batches into an AI model, or distributing work across processors, chunking allows you to handle data more efficiently. Python offers several ways to chunk lists and iterables. Some use built-in tools.