Python adding arrays of different sizes - upper bound?

1653 views python

I want to add several arrays together but they have different sizes.

I think the code should look like this

commission = [0.55,0.03,0.025,0.025]
interest = [0.05,0.045]
premium = 10
fund = []

for i = 1 to 120
        fund[i] = premium * (1 - commission[i]) + interest[i] * fund[i-1]

But the issue is that this will go out of bounds. I just want the commission[4] to extend to all 120 periods. Same with the interest array. Usually in the past I have used the "upperbound" command within the for loop to do this calculation.

How is it done in python?


answered question

1 Answer


Which values should be used for calculations above sizes of the arrays? You can e.g. repeat the arrays by typing


to get 120 entries.

posted this

Have an answer?


Please login first before posting an answer.