A = [1,2,3,4,5,6]
B = A[:len(A)//2]
C = A[len(A)//2:]

If you want a function:

def split_list(a_list):
    half = len(a_list)//2
    return a_list[:half], a_list[half:]

A = [1,2,3,4,5,6]
B, C = split_list(A)
Answer from Jason Coon on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ numpy โ€บ numpy_array_split.asp
NumPy Splitting Array
Splitting is reverse operation of Joining. Joining merges multiple arrays into one and Splitting breaks one array into multiple.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-program-to-split-a-list-into-two-halves
Python Program to Split a List into Two Halves - GeeksforGeeks
July 23, 2025 - This function automatically handles splitting the list and is efficient for large datasets. ... import numpy as np a = [1, 2, 3, 4, 5, 6] # Creates two sub-arrays, dividing the list evenly split_lst = np.array_split(a, 2) # Assign the first half to x x = split_lst[0] # Assign the second half to y y = split_lst[1] print(x) print(y)
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.1 โ€บ reference โ€บ generated โ€บ numpy.array_split.html
numpy.array_split โ€” NumPy v2.1 Manual
>>> import numpy as np >>> x = np.arange(8.0) >>> np.array_split(x, 3) [array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]
๐ŸŒ
Python.org
discuss.python.org โ€บ python help
How do i split this array into more arrays at each dash? - Python Help - Discussions on Python.org
April 9, 2024 - ['A- 0.5', 'WC- 0.5', 'WC- 0.0', 'n- 0.0', 'WC- 0.3333333333333333', 'ABC- 1.7777777777777777', 'DEF- 1.0', 'GHI- 1.5']
Find elsewhere
๐ŸŒ
DataCamp
datacamp.com โ€บ doc โ€บ numpy โ€บ split
NumPy split()
The `split()` function in NumPy is used to divide an array into multiple sub-arrays.
๐ŸŒ
Codecademy
codecademy.com โ€บ article โ€บ split-numpy-arrays
How to Split Arrays in NumPy? | Codecademy
NumPy is a powerful, open-source library for scientific computing in Python. It is popular for its efficient handling of multi-dimensional arrays, an essential data structure for performing numerical calculations. In this guide, weโ€™ll discuss in detail how to split NumPy arrays using several functions like np.split(), np.array_split(), np.hsplit(), np.vsplit(), and np.dsplit().
๐ŸŒ
Imperial College London
python.pages.doc.ic.ac.uk โ€บ lessons โ€บ numpy โ€บ 05-manipulation โ€บ 03-split.html
Introduction to NumPy and Matplotlib > Array split | Python Programming | Department of Computing | Imperial College London
>>> x = np.arange(1, 19).reshape((2, 9)) >>> print(x) [[ 1 2 3 4 5 6 7 8 9] [10 11 12 13 14 15 16 17 18]] >>> y = np.split(x, 3, axis=1) # split on axis 1 into 3 evenly-sized sub-arrays >>> print(y[0]) [[ 1 2 3] [10 11 12]] >>> print(y[1]) [[ 4 5 6] [13 14 15]] >>> print(y[2]) [[ 7 8 9] [16 17 18]] >>> y = np.split(x, 2, axis=0) # split on axis 0 into 2 evenly-sized sub-arrays >>> print(y[0]) [[1 2 3 4 5 6 7 8 9]] >>> print(y[1]) [[10 11 12 13 14 15 16 17 18]] >>> y = np.split(x, 4, axis=1) # attempt to split on axis 1 into 4 evenly-sized sub-arrays ValueError: array split does not result in an equal division
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how do i split a list of numbers into equal size (of an array?) to pass into an api as an input?
r/learnpython on Reddit: How do I split a list of numbers into equal size (of an array?) to pass into an API as an input?
January 28, 2025 -

I have a file abc.txt:

1234

2678

3345

4987

5765

6864

7479

I want to split the list into equal chunks (into an array?) so that it looks like this:

group 1: '1234','2678','3345'

group 2: '4987','5765','6864'

group 3: '7479'

the goal is to pass those IDs into an API. I can loop through each one of them single-y but one API call can take 30 values at a time, so it would be more efficient to send chunks of 30. (I have that part of the code working!)

my Python version is 3.6 (I know) , so cant use modules like itertools, etc. I need something easy using simple for, while loops if we can.

this is a follow-up to my original post here.

can anyone help or point me to the right direction. thank you!

๐ŸŒ
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 - If your data is strictly numeric, then you can try leveraging one of the functions provided by the esteemed NumPy library to split a sequence of numbers into chunks. Thanks to its unmatched speed, NumPy is well suited to all kinds of number crunching, which would otherwise run significantly slower when implemented in pure Python. ... This scientific library comes with several array-splitting functions, which you can use to divide an array into smaller parts.
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-split-list
How to Split Lists in Python: Basic and Advanced Methods | DataCamp
June 21, 2024 - Edge cases may occur in Python list split when you fail to account for some scenarios. For example, the snippet below indicates a function trying to split lists into chunks of 5 when the list contains only 4 items. import numpy as np my_list = [1, 2, 3, 4] chunks = np.array_split(my_list, 5) print(chunks) # Expected output: # [array([1]), array([2]), array([3]), array([4]), array([], dtype=int32)]
๐ŸŒ
VectorBT
vectorbt.dev
Getting started - VectorBT
Strategies and instruments aren't the only things that can act as separate features โ€” time can too. If we want to find out when our strategy performs best, we can backtest over multiple time periods. VectorBT can split one time period into many segments of the same length and frequency and represent them as distinct columns.
๐ŸŒ
datagy
datagy.io โ€บ home โ€บ python posts โ€บ python lists โ€บ python: split a list (in half, in chunks)
Python: Split a List (In Half, in Chunks) โ€ข datagy
December 30, 2022 - This function allows you to split an array into a set number of arrays. Letโ€™s see how we can use NumPy to split our list into 3 separate chunks: # Split a Python List into Chunks using numpy import numpy as np a_list = [1, 2, 3, 4, 5, 6, 7, 8, 9] our_array = np.array(a_list) chunked_arrays = np.array_split(our_array, 3) chunked_list = [list(array) for array in chunked_arrays] print(chunked_list) # Returns: [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
๐ŸŒ
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 - Explanation: List comprehension extracts sub-arrays from a using index ranges in b, slices a[i:j+1] to include the end index, and converts each sub-array to a list with .tolist(). For loop with list append offers a more explicit but less efficient way to split lists.
๐ŸŒ
LeetCode
leetcode.com โ€บ problems โ€บ split-array-largest-sum
Split Array Largest Sum - LeetCode
Split Array Largest Sum - Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized. Return the minimized largest sum of the split.
๐ŸŒ
Renovate Docs
docs.renovatebot.com โ€บ configuration-options
Configuration Options - Renovate Docs
Here's an example where additionalBranchPrefix can help you. Say you're using a monorepo and want to split pull requests based on the location of the package definition, so that individual teams can manage their own Renovate pull requests.
๐ŸŒ
NumPy
numpy.org โ€บ doc โ€บ 2.3 โ€บ reference โ€บ generated โ€บ numpy.array_split.html
numpy.array_split โ€” NumPy v2.3 Manual
>>> import numpy as np >>> x = np.arange(8.0) >>> np.array_split(x, 3) [array([0., 1., 2.]), array([3., 4., 5.]), array([6., 7.])]
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ splitting-arrays-in-numpy
Splitting Arrays in NumPy - GeeksforGeeks
December 23, 2025 - DSA Python ยท Data Science ยท NumPy ยท Pandas ยท Practice ยท Django ยท Flask ยท Last Updated : 23 Dec, 2025 ยท Splitting arrays means dividing a single NumPy array into multiple smaller sub-arrays.
๐ŸŒ
Udemy
udemy.com โ€บ development
Machine Learning A-Z [2026]: ML, DL, AI with AWS, Python & R
June 13, 2026 - The lecture explores various machine learning algorithms and demonstrates how to build, train, and make predictions with ML models using Python. You'll gain hands-on experience with feature engineering, handling missing values, and splitting data into training and test sets.
Rating: 4.5 โ€‹ - โ€‹ 206K votes