I'm trying to create a function my_function(A), that takes a list A of N numbers, and outputs a list B of N+1 numbers with B[0]=0 and B[n]=B[n-1]+A[n-1] where n<N.
For example, if A is the list [1,2,3,4,5], B[1]=B[0]+A[0]=0+1, B[2]=B[1]+A[1]=1+2 and the final output would be [0,1,3,6,10,15]
I need to use only numpy, at most.
My code is
def my_function(A):
for n in range(len(A)):
B[0]=0
B[n]=B[n-1]+A[n-1]
return B[n]
I can't find a way to define B without errors