Question: I need help writing a function using recursion in Python. 2. Write a function compare(list1, list2) that takes as inputs two lists of numbers, list1
I need help writing a function using recursion in Python. 
2. Write a function compare(list1, list2) that takes as inputs two lists of numbers, list1 andlist2, and that uses recursion to compute and return the number of values in listl that are smaller than their corresponding value in list2. In other words, the function should compare list1[0] with list2[0], list1[1] with list2[1], list1[2] with list2[2], etc, and it should return the number of positions at which the value from list1 is smaller than the value from list2. For example >>compare([5, 3, 7, 9, 1], [2, 4, 7, 8, 3]) The above call returns 2, because: .in position 0, 5> 2 .in position 1, 3 8 . in position 4, 1 3 Thus, there are two positions (1 and 4) at which the value from list1 is smaller than the value from list2. Note that it is possible for the two lists to have different lengths, in which case the function should only compare the positions at which the two lists both have values. >>>compare([4, 2, 3, 7], [1, 5]) >>> compa reCE4, 2, 3], [6, 5, 0, 3]) >compare([5, 3], [1) >compare(L, [5, 3, 7]) # 4 > 1; 2
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
