Question: 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

Answer: 
I would handle this while indexing the list. All out of bounds accesses should refer to the last element by default. 

You'd want to do something of the like:

```
def get_graceful_overflow(lst, idx):
    return lst[min(idx, len(lst) - 1)]

```

Now substitute calls to `commission[i]` with `get_graceful_overflow(commission, i)`. And similar for `interest`.
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.