def multAll(k, A):
return multAllRec(k,A,0)
def multAllRec(k,A,i):
if i == A[len(A)-1]:
return
if i < len(A):
A[i] = A[i]*k
return A[i]
return multAllRec(k, A, i+1)
multAll(10,[5,12,31,7,25])
I'm using python to create a recursive function that multiplies the elements in the array by the variable k. Here in this code I am doing the recursive function but it is only returning 50 when it should be returning [50,120,310,70,250]. It is only multiplying the first element of the array.
What am I doing wrong?