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)
More Related Contents:
- How do you split a list into evenly sized chunks?
- How to split a string into a list?
- Split a Pandas column of lists into multiple columns
- Split a string by a delimiter in python
- How to split elements of a list?
- Splitting a list based on a delimiter word
- How do I split a list into equally-sized chunks?
- How do I split a string into a list?
- Splitting on last delimiter in Python string?
- Python split string into multiple string [duplicate]
- How to split strings inside a list by whitespace characters
- Convert string to list. Python [string.split() acting weird]
- Attribute Error: ‘list’ object has no attribute ‘split’
- Convert list of strings to dictionary
- How to transform string of space-separated key,value pairs of unique words into a dict
- How do I split a string into a list of words?
- How to split by comma and strip white spaces in Python?
- How do I concatenate items in a list to a single string?
- Why does this iterative list-growing code give IndexError: list assignment index out of range?
- Slicing a list in Python without generating a copy
- Take the content of a list and append it to another list
- Accessing the list while being sorted
- python split a string with at least 2 whitespaces
- How does the max() function work on list of strings in python?
- How do I sort this list in Python, if my date is in a String?
- How do I send list of dictionary as Body parameter in FastAPI?
- Python Sort One List According to Another List
- Mapping dictionary value to list
- How to change variables fed into a for loop in list form
- list extend() to index, inserting list elements not only to the end