Question: help! thank you ! Write a function mul_pairs(vals1, vals2) that takes as inputs two lists of numbers, vals1 and vals2, and that uses recursion to
help! thank you !
Write a function mul_pairs(vals1, vals2) that takes as inputs two lists of numbers, vals1 and vals2, and that uses recursion to construct and return a new list in which each element is the product of the elements at the corresponding positions in the original lists. For example: \[ \begin{array}{l} \text { mul_pairs( }[7,2,3],[4,5,6]) \\ \text { result: }[28,10,18] \end{array} \] Note that the elements in the result are obtained by multiplying the corresponding elements from the original lists (74,25, and 36). Base cases: If the two lists do not have the same length or if either list is empty, the function should return an empty list ([]). These are the only base cases that you need! Here are some other examples: Hints: - Here is some pseudocode (i.e., a mixture of Python code and descriptive text) that shows our recommended approach to this problem: def mul_pairs(vals1, vals 2 ): """ docstring goes here """ if the lists don't have the same length: return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
