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
๐ŸŒ
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 - A second loop iterates over the second part of the list and adds each element to second_half. For working with numeric data or using the numpy library, numpy.array_split() provides a clean way to split lists (or arrays) into two or more parts.
Discussions

How can I split a Python list in half? - Ask a Question - TestMu AI (formerly LambdaTest) Community
How can I split a Python list in half? For example, if I have the list: A = [0, 1, 2, 3, 4, 5] I want to split it into two smaller lists: B = [0, 1, 2] C = [3, 4, 5] What is the best way to achieve this in Python? More on community.testmuai.com
๐ŸŒ community.testmuai.com
0
January 20, 2025
python - What is the most efficient way to split a list evenly in half - Stack Overflow
I need to split a list into halves such that if it has an odd length the middle element is ignored entirely, I have a function for this, but it's quite slow for what I'm trying to do. My function (variables renamed because they make no sense out of context): def splitList(array): half = ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Splitting an Array into two and Swapping the First Half With the Second Half
So this problem could actually be solved without any loops at all, just by using array splicing, you may want to take a look at that. Also, I'm not 100% sure, but I think in your odd example the output isn't actually what you want, since the 4 is out of place More on reddit.com
๐ŸŒ r/learnpython
13
3
May 18, 2020
Text file list split in half and save into two files
Don't name your variable 'file', that is a reserved word in Python. And, the same with 'list': with open('file.txt') as fh_read, open('file1.txt', 'w') as fh_write1, open('file2.txt', 'w') as fh_write2: entries = fh_read.readlines() [fh_write1.write(entry) for entry in entries[:len(entries) // 2]] [fh_write2.write(entry) for entry in entries[len(entries) // 2:]] Edit: Fair argument from u/lanemik ; upvote tossed over there. Though, I'd not strip() because that could remove important characters. I'm sticking with readlines() and do not mind comprehensions without assignment, personally. More on reddit.com
๐ŸŒ r/learnpython
8
3
October 22, 2018
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ article โ€บ python-program-to-split-a-list-into-two-halves
Python Program to Split a List into Two Halves
March 27, 2026 - The most straightforward method to split a list is using Python's slicing technique. This approach divides the list at a specific index, creating two separate parts. When a list has an even number of elements, splitting results in two equal halves ?
๐ŸŒ
pythoncodelab
pythoncodelab.com โ€บ home โ€บ how to split a list in half python
How to split a list in half Python - - pythoncodelab
November 2, 2024 - We have used list comprehension โ€œ[lst[i * part_size:(i + 1) * part_size] for i in range(parts)]โ€ . In this code line we iterate through the range of parts and slice the list accordingly.
๐ŸŒ
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 - You can easily split a Python list in half using list indexing. As you learned above, you can select multiple items in a list using list slicing.
Find elsewhere
๐ŸŒ
Entechin
entechin.com โ€บ home โ€บ how to split a list in half using python
How to Split a List in Half using Python Tutorial - Entechin
July 6, 2024 - In this case, the floor operator ... length of 4. Pythonโ€™s NumPy library provides a built-in function, array_split(), that can divide a list into n parts....
๐ŸŒ
Python Help
pythonhelp.org โ€บ python-lists โ€บ how-to-split-a-list-in-half-python
How to Split a List in Half in Python
October 17, 2023 - Python provides us an easy way to split a list into two halves using its in-built function โ€˜middleโ€™. The Python list โ€˜middleโ€™ method splits the list in half and returns a new list containing both ends of the original list.
๐ŸŒ
Altcademy
altcademy.com โ€บ blog โ€บ how-to-split-a-list-in-python
How to split a list in Python - Altcademy.com
June 13, 2023 - The simplest way to split a list in Python is by using slicing. Slicing allows us to extract a portion of the list by specifying the start and end indices. The general syntax for slicing is list[start:end], where start is the index of the first ...
๐ŸŒ
Finxter
blog.finxter.com โ€บ home โ€บ learn python blog โ€บ how to split a list in half in 5 ways
How to Split a List in Half in 5 Ways - Be on the Right Side of Change
July 15, 2022 - Above defines a function with one (1) argument (split_half(pop)). This function splits the list in half using the Right Shift Operator and returns the results as a Tuple with two (2) nested lists.
๐ŸŒ
TestMu AI Community
community.testmuai.com โ€บ ask a question
How can I split a Python list in half? - Ask a Question - TestMu AI (formerly LambdaTest) Community
January 20, 2025 - How can I split a Python list in half? For example, if I have the list: A = [0, 1, 2, 3, 4, 5] I want to split it into two smaller lists: B = [0, 1, 2] C = [3, 4, 5] What is the best way to achieve this in Python?
๐ŸŒ
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 - 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.
๐ŸŒ
Finxter
blog.finxter.com โ€บ 5-best-ways-to-split-a-python-list-into-two-halves
5 Best Ways to Split a Python List into Two Halves โ€“ Be on the Right Side of Change
This method involves splitting a list into two halves by using slice notation. Slice notation in Python allows us to access a subset of a list with a start, stop, and step parameters. By calculating the midpoint of the list, we can easily create two new lists representing the two halves.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ splitting an array into two and swapping the first half with the second half
r/learnpython on Reddit: Splitting an Array into two and Swapping the First Half With the Second Half
May 18, 2020 -

Here's the algorithm:

array = [int(num) for num in input().split()]
len = len(array)

mid=int(len/2)

if mid%2==0:
    for i in range(mid):
        temp=array[i]
        array[i]=array[mid+i]
        array[mid + i]=temp
else:
    for i in range(mid):
        temp=array[i]
        array[i]=array[mid+i+1]
        array[mid + i + 1]=temp

print(array)

The issue is, the program has to decide between two loops depending on the length of the array (odd or even), which I think is very inefficient. Can someone suggest a way to bring this down to a single loop?

Sample I/O for even:

1 2 3 4 5 6 7 8
[5, 6, 7, 8, 1, 2, 3, 4]

Sample I/O for odd:

1 2 3 4 5 6 7 
[5, 6, 7, 4, 1, 2, 3]
๐ŸŒ
Kite
kite.com โ€บ python โ€บ answers โ€บ how-to-split-a-list-in-half-in-python
Kite is saying farewell - Code Faster with Kite
November 20, 2022 - P.S. Most of our code has been open sourced on Github here. It includes our data-driven Python type inference engine, Python public-package analyzer, desktop software, editor integrations, Github crawler and analyzer, and much more.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-ways-to-spilt-the-list-by-some-value
How to Split the list by some value ? - GeeksforGeeks
December 18, 2024 - Method #1 : Using itemgetter ... Splitting a list into two halves is a common operation that can be useful in many cases, such as when dealing with large datasets or when performing specific algorithms (e.g., merge sort).