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 OverflowW3Schools
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.
W3Schools
w3schools.com › python › ref_string_split.asp
Python String split() Method
Python Examples Python Compiler Python Exercises Python Quiz Python Challenges Python Practice Problems Python Server Python Syllabus Python Study Plan Python Interview Q&A Python Training ... The split() method splits a string into a list.
W3Schools
devcom.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.
Top answer 1 of 16
361
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)
2 of 16
109
A little more generic solution (you can specify the number of parts you want, not just split 'in half'):
def split_list(alist, wanted_parts=1):
length = len(alist)
return [ alist[i*length // wanted_parts: (i+1)*length // wanted_parts]
for i in range(wanted_parts) ]
A = [0,1,2,3,4,5,6,7,8,9]
print split_list(A, wanted_parts=1)
print split_list(A, wanted_parts=2)
print split_list(A, wanted_parts=8)
W3Schools
w3schools.com › python › numpy › trypython.asp
W3Schools online PYTHON editor
Run ❯ Get your own Python server · ❯Run Code Ctrl+Alt+R Change Orientation Ctrl+Alt+O Change Theme Ctrl+Alt+D Go to Spaces Ctrl+Alt+P · [array([1, 2]), array([3, 4]), array([5, 6])]
Educative
educative.io › answers › what-is-the-array-split-method-in-numpy
What is the array split() method in Numpy?
The numpy.array_split() method in Python is used to split an array into multiple sub-arrays of equal size.
NumPy
numpy.org › doc › stable › reference › generated › numpy.split.html
numpy.split — NumPy v2.5 Manual
Split an array into multiple sub-arrays as views into ary.
w3resource
w3resource.com › numpy › manipulation › split.php
NumPy: numpy.split() function - w3resource
April 24, 2026 - In the above code, the numpy.split() function is used to split an input array 'a' at specified positions given as a list argument [4, 5, 6, 7]. This will split the array 'a' into subarrays at the positions 4, 5, 6, and 7.
Medium
medium.com › @pamyaola › 5-splitting-arrays-numpy-functions-4ccaa52c376
5 Splitting arrays in NumPy(with working and breaking examples). | by Pamyaola | Medium
June 27, 2023 - Vsplit raises an exception if an equal split is not possible. Provide links to your references and other interesting articles about NumPy arrays: NumPy official tutorial : https://numpy.org/doc/stable/user/quickstart.html · https://www.w3schools.com/python/numpy/numpy_array_split.asp ·
W3Schools
w3schools.com › python › ref_string_rsplit.asp
Python String rsplit() Method
Python Examples Python Compiler ... Study Plan Python Interview Q&A Python Training ... The rsplit() method splits a string into a list, starting from the right....
Python Guides
pythonguides.com › how-to-split-a-string-into-an-array-in-python
How To Split A String Into An Array In Python?
December 31, 2024 - This tutorial will help you understand various methods of splitting strings in Python with examples. To split a string into an array in Python, use the split() method, which divides the string based on a specified delimiter, defaulting to whitespace. For example, string.split(',') will split ...
PythonForBeginners
pythonforbeginners.com › home › how to use split in python
How to use Split in Python - PythonForBeginners.com
January 30, 2021 - To do this, you use the python split function. What it does is split or breakup a string and add the data to a string array using a defined separator.
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
Codecademy
codecademy.com › docs › python:numpy › built-in functions › .split()
Python:NumPy | Built-in Functions | .split() | Codecademy
April 4, 2025 - Learn the basics of Python 3.13, one of the most powerful, versatile, and in-demand programming languages today. ... If an integer, it divides the array into equal-sized sub-arrays. If a list of indices, it splits at the specified positions.