Python adding arrays of different sizes - upper bound?

1653 views python
-3

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?

Thanks

answered question

1 Answer

7

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

[0.55,0.03,0.025,0.025]*30 

to get 120 entries.

posted this

Have an answer?

JD

Please login first before posting an answer.