Question: The following corresponds to python programming. Will upvote. 1) Write a function, append_n_elements_from_2nd_to_1st(la, lb, n) that performs the following tasks. This function receives two lists

The following corresponds to python programming. Will upvote.

1) Write a function, append_n_elements_from_2nd_to_1st(la, lb, n) that performs the following tasks.

  • This function receives two lists la and lb, and a number n as arguments.

  • It moves the last n elements in lb to la in the reversed order. See expected outcome below.

  • It checks if the number of elements in lb is equal to or greater than n. If not, it prints "Error: the 2nd list must have at least 'n' number of elements."

a) Complete the following function. DO NOT CHANGE THE FUNCTION NAME AND ARGUMENTS! They will be used to test your answers. def append_n_elements_from_2nd_to_1st(la, lb, n) 

---------

# The following code is provided for your test. You can modify it as you want, to test your function. A = [1,2,3] B = [4,5,6,7,8,9] append_n_elements_from_2nd_to_1st(A, B, 4) print(A) print(B) print(' ') A = [1,2,3,4,5,6] B = [7,8,9] append_n_elements_from_2nd_to_1st(A, B, 6) print(A) print(B)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!