splitting a list in half python code example
Example: 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]