Question: Complete the combine_two_lists() function that takes two integer lists as parameters: num_list1 and num_list2. If these two lists have different lengths, the function returns a

Complete the combine_two_lists() function that takes two integer lists as parameters: num_list1 and num_list2.

If these two lists have different lengths, the function returns a new list made by concatenating num_list1 with num_list2.

If these two lists have the same length, the function returns a new list with the same number of elements. The first element of the new list is the product of the last element of num_list1 with the first element of num_list2. The second element of the new list is the product of the second last element of num_list1 with the second element of num_list2, and so on. Therefore if:

num_list1 = [a, b, c, d]

and

num_list2 = [e, f, g, h]

the the new list would have the elements:

[de, cf, bg, ah]

Some examples of the function being used are shown below.

For example:

Test Result
num_list1 = [1,2,3,4] num_list2 = [5,6,7,8] new_list = combine_two_lists(num_list1, num_list2) print(new_list)
[20, 18, 14, 8]
num_list1 = [1,2,3] num_list2 = [4,5,6,7] new_list = combine_two_lists(num_list1, num_list2) print(new_list)
[1, 2, 3, 4, 5, 6, 7]

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!