I would like to define a function where you input multiple numbers and the function will add up the first two, and then add the answer to the third, then the answer to this to the fourth and so on until the numbers have all been incrementally added up. For example:
def function(x1, x2, x3, x4):
ind_1 = x1 + x2
ind_2 = ind_1 + x3
ind_3 = ind_2 + x4
return x1, ind_1, ind_2, ind_3
function(175, 107, 107, 95)
OUT: (175, 282, 389, 484)
How could I scale this up so it does it repeatedly on a generic list of numbers which change every time I use it without having to manually write out all the sums in the function?
Thanks!