Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

split list in half python

print(a_list)
length = len(a_list)
middle_index = length//2
first_half = a_list[:middle_index]
second_half = a_list[middle_index:]
print(first_half)
print(second_half)

>> [1, 2, 3, 4]
>> [1, 2]
>> [3, 4]
 
PREVIOUS NEXT
Tagged: #split #list #python
ADD COMMENT
Topic
Name
8+8 =