Python Following Recursive Function Logical Error Offer Fix Produce Correct Result Def Myf Q37267042

(Python) The following recursive function has a logical error.What can you offer to fix it and produce the correct result?

def myFunction(a):
“”” pre: a is a list of integer numbers, len(a) is evennumber
post: returns the list of the sums of the last and first,
second and second to last, thrid and thrid to last, …
Example: for the list [1,4,3,7,5,6]
the function returns the list [7,9,10],
i.e. 1+6 = 7, 4+5 = 9, 3+7 – 10″””
r = []
return helper(a,r,0,len(a)-1)

def helper(a, result, left, right):
“””pre: a is the original list, result is the resulting list,
left is the index of the element to the left
for the sum to

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.