I'd say

chunks = [data[x:x+100] for x in range(0, len(data), 100)]

If you are using python 2.x instead of 3.x, you can be more memory-efficient by using xrange(), changing the above code to:

chunks = [data[x:x+100] for x in xrange(0, len(data), 100)]
Answer from DanRedux on Stack Overflow
🌐
DataCamp
datacamp.com › tutorial › python-split-list
How to Split Lists in Python: Basic and Advanced Methods | DataCamp
June 21, 2024 - Python split list at index is likely the most common split list technique. The slicing method ensures the Python list is split into sublists at the specified index.
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
python - Slicing a list into a list of sub-lists - Stack Overflow
What is the simplest and reasonably efficient way to slice a list into a list of the sliced sub-list sections for arbitrary length sub lists? For example, if our source list is: input = [1, 2, 3,... More on stackoverflow.com
🌐 stackoverflow.com
How to Split a Python List or Iterable Into Chunks – Real Python
While you have nothing in the standardlib, you have an example function for this in the itertools documentation : def grouper(iterable, n, *, incomplete='fill', fillvalue=None): "Collect data into non-overlapping fixed-length chunks or blocks" # grouper('ABCDEFG', 3, fillvalue='x') --> ABC DEF Gxx # grouper('ABCDEFG', 3, incomplete='strict') --> ABC DEF ValueError # grouper('ABCDEFG', 3, incomplete='ignore') --> ABC DEF args = [iter(iterable)] * n if incomplete == 'fill': return zip_longest(*args, fillvalue=fillvalue) if incomplete == 'strict': return zip(*args, strict=True) if incomplete == 'ignore': return zip(*args) else: raise ValueError('Expected fill, strict, or ignore') I'd use that. More on reddit.com
🌐 r/Python
3
54
February 9, 2023
How to split a list at every certain element?
Loop through list, Append current element to temporary sublist, If current element is 0, do something with sublist (print?) and reset to []. More on reddit.com
🌐 r/learnpython
10
5
June 28, 2021
🌐
AskPython
askpython.com › python › list › splitting-lists-into-sub-lists
Splitting Lists into Sub-Lists in Python: Techniques and Advantages - AskPython
April 10, 2025 - The isslice() function in Python splits a list into sub-lists. We can directly use this function with a loop to implement the example. In this method, we must provide a step in which the list is divided.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-split-list-into-lists-by-particular-value
Split list into lists by value - Python - GeeksforGeeks
July 11, 2025 - Explanation: Loops through the list a, splitting it into sublists at occurrences of b and appending segments without b to the result.
🌐
Delft Stack
delftstack.com › home › howto › python › python split list into multiple lists
How to Split List Into Sublists in Python | Delft Stack
February 2, 2024 - One simple and effective way to split a list into sublists is by using a loop. The fundamental concept is to iterate through the original list and group elements into sublists based on specified criteria, such as a fixed chunk size.
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-split-lists-in-python
How to Split Lists in Python? - GeeksforGeeks
July 23, 2025 - Explanation: The numpy.array_split function divides the list into sublists, ensuring all elements are distributed.
🌐
MAC Address Lookup
aruljohn.com › home › articles › code
How to Break a Python List into Sublists or Slices
August 27, 2024 - Learn how to break a Python list into a list of lists or tuples using itertools.batched, list comprehension, slicing and for loops with append.
Find elsewhere
🌐
CoenRaets
jsonviewer.ai › split-list-into-multiple-lists-in-python
Split List into Multiple Lists in Python - [4 Easy Ways with Examples] - JSON Viewer
July 4, 2023 - The range() function uses three arguments: start, end, and step to generate a sequence of numbers. The output of slicing is then added to a new list using the list comprehension syntax. numpy.array_split() is a function inside the NumPy library that splits a given array into multiple sub-lists.
🌐
Reddit
reddit.com › r/learnpython › split list into smaller lists
r/learnpython on Reddit: Split list into smaller lists
January 6, 2021 -

Hi all! I will kick myself when you tell me how to do this, but I'm stumped, how do I split the following list into smaller lists, where 'x' is the separator. In other words, there will be 3 new lists not containing 'x'

myList = ['one', 'two', 'x', 'three', 'x', 'four', 'five']

bonus question, when I try (infinite) while loops on the above in Sublime, ctr+c doesn't seem to stop the process--I have to go into activity monitor to kill the process with my fan going crazy. OSX

Thank you!

Top answer
1 of 4
3
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
2 of 4
1
One approach is to join() all the strings with a delimiter such as "|" which gives you: "one|two|x|three|x|four|five" Then split on "x", giving: ['one|two|', '|three|', '|four|five'] Then you iterate through that list, using strip() to remove any delimiters at the ends of each string, and append the sublist you get from using split() on a string like "one|two" to a result list, which you return. A little messy, but I can't think of another approach that's better at the moment.
🌐
Python Help
pythonhelp.org › python-lists › how-to-split-list-into-sublists-python
How to Split List into Sublists Python
print(next(sublists)) # prints [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(next(sublists)) # prints [10, 11, 12, 13, 14, 15, 16, 17, 18, 19] Remember this is just a simple demonstration of chunking. Depending on the size and complexity of your data you might need to adapt the approach (e.g., using memory mapped files or pandas DataFrame for large data sets). Written for working developers, Coding with AI goes beyond hype to show how AI fits into real production workflows. Learn how to integrate AI into Python projects, avoid hallucinations, refactor safely, generate tests and docs, and reclaim hours of development time—using techniques tested in real-world projects.
🌐
Coding-engineer
coding-engineer.com › 2023 › 04 › 14 › split-python-list-into-sublists-base-on-index-indices
Split Python List into sublists base on index/indices
April 13, 2023 - #Since the split will occur at the index ie happen before 'End of review' # hence we +1 to make the split after 'End of review' index_list.pop() index_list = [item +1 for item in index_list] print (index_list) #Split List into sublists reviews_sublist = [sublist.tolist() for sublist in np.split(reviews_list, index_list)] print(reviews_sublist) #Print sublist as independent lists for sublist in reviews_sublist: print(sublist) print('\n')
🌐
Kodeclik
kodeclik.com › how-to-split-a-list-into-sublists-python
Split a list into sublists of given lengths
October 16, 2024 - To split a list into sublists of predefined lengths in Python there are two approaches. 1. use the islice() method from the itertools package, or 2. Use the accumulate and zip methods to break down the list into the parts you require.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-split-a-list-into-sublists-of-given-lengths
Python | Split a list into sublists of given lengths - GeeksforGeeks
February 20, 2023 - Method #1: Using islice to split a list into sublists of given length, is the most elegant way. ... # Python code to split a list # into sublists of given length.
🌐
GeeksforGeeks
geeksforgeeks.org › python › break-list-chunks-size-n-python
Break a List into Chunks of Size N in Python - GeeksforGeeks
October 28, 2025 - List comprehension is an efficient method for chunking a list into smaller sublists. This method creates a list of lists, where each inner list represents a chunk of the original list of a given size.
🌐
GeeksforGeeks
geeksforgeeks.org › python › split-a-python-list-into-sub-lists-based-on-index-ranges
Split a Python List into Sub-Lists Based on Index Ranges - GeeksforGeeks
July 23, 2025 - It extracts a[i:j+1] for each (i, j), ensuring inclusion of the end index. ... itertools.islice() provides a memory-efficient way to split lists or iterators without creating unnecessary copies.
🌐
TutorialsPoint
tutorialspoint.com › custom-list-split-in-python
Custom list split in Python
May 4, 2020 - from itertools import chain data_list ... splitting : ", split_points) # to perform custom list split sublists = zip(chain([0], split_points), chain(split_points, [None])) split_list = list(data_list[i : j] for i, j in sublists) ...
🌐
Real Python
realpython.com › how-to-split-a-python-list-into-chunks
How to Split a Python List or Iterable Into Chunks – Real Python
January 27, 2025 - The chunks yielded by split_sequence() are of the same type as the iterable that you passed as input. In the first case, they’re strings because you passed a string argument to the function, whereas in the second case, they’re sublists of the original list.
🌐
Bomberbot
bomberbot.com › python › mastering-python-split-a-list-into-sublists-of-given-lengths
Mastering Python: Split a List into Sublists of Given Lengths - Bomberbot
We then use a list comprehension to create sublists, where islice() efficiently extracts elements from the iterator based on the specified length. This method is highly efficient as it avoids creating unnecessary copies of the list, making it ideal for large datasets. Another powerful approach combines Python's list slicing capabilities with the accumulate function from itertools. This method is particularly useful when you need to keep track of the splitting positions:
🌐
Medium
medium.com › ai-does-it-better › splitting-a-list-into-evenly-sized-chunks-in-python-a993786a6b6e
Splitting a List into Evenly Sized Chunks in Python | by Doug Creates | AI Does It Better | Medium
March 19, 2024 - Dividing a list into evenly sized chunks involves calculating the size of each chunk and then iterating over the list to slice it into sublists. This transforms a single list into a list of lists, each containing a specified number of elements.