Search for question
Question

4. Write a Python function called interleave that accepts two lists as arguments (list_1 and list_2). The two lists sent as arguments to the function should consist of the same number of elements. The function should create a new list (list_3) that results from the interleaving of list_1 and list_2. To interleave list_1 and list_2, the function should set the first element of list_3 equal to the first element of list_1. Next it should set the second element of list_3 equal to the first element of list_2, the third element of list_3 equal to the second element of list_1, the fourth element of list_3 equal to the second element of list_2, etc. So, for example, if the lists received by the function are: list_1 = ['a', 'c', 'e', 'g', 'i'] and list_2 = ['b', 'd', 'f', 'h', 'j'], they should be interleaved to form list_3 = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'], and list_3 should be sent back as a return value to the calling code. Make sure to test your function from the main program of your Python file and print the result to ensure it works correctly. As always, it is a good idea to run multiple tests to ensure the function works for all lists it might receive as arguments.

Fig: 1