Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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: returnStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started