Write a function half_and_half that takes in a list and change the list such that the elements of the second half are now in the first half.

For example, if the size of list is even and content of list is as follows :
my_liist = [10,20,30,40,50,60]
The output should be
[40,50,60,10,20,30]
if the size of list is odd and content of list is as follows :
my_liist = [10,20,30,40,50,60,70]
The output should be
[50,60,70,40,10,20,30]

Source Code

def half_and_half(my_list):
    if len(my_list)%2 == 0:
        start = 0
    else:
        start = 1
        
    L = len(my_list)//2
    
    for i in range(L):
        temp = my_list[i]
        my_list[i] = my_list[i+L+start]
        my_list[i+L+start] = temp

my_list = [10,20,30,40,50,60,70]
half_and_half(my_list)
print(my_list)

Output

[50, 60, 70, 40, 10, 20, 30]