value of the variable amounts is now list object that itself contains four int values it is this list object that gets passed to addinterest and is therefore also the value of balances next addinterest executes the loop goes through each index in the range length and updates that item in balances the result is shown in figure you'll notice in the diagram def test()amounts [ , , , rate addinterest(amounts,rateprint(amountsdef addinterest(balancesrate)for in range(len(balances))balances[ibalances[ ( +raterate rate balances amounts figure list modified in addinterest that left the old values ( just hanging around did this to emphasize that the numbers in the value boxes have not changed instead what has happened is that new values were createdand the assignments into the list caused it to refer to the new values the old values will actually get cleaned up when python does garbage collection it should be clear now why the list version of the addinterest program produces the answer that it does when addinterest terminatesthe list stored in amounts now contains the new balancesand that is what gets printed notice that the variable amounts was never changed it still refers to the same list that it did before the call to addinterest what has happened is that the state of that list has changedand this change is visible back in the calling program now you really know everything there is to know about how python passes parameters to functions parameters are always passed by value howeverif the value of the variable is mutable object (like list or graphics object)then changes to the state of the object will be visible to the calling program this latter situation is another example of the aliasing issue discussed in functions and program structure so farwe have been discussing functions as mechanism for reducing code duplicationthus shortening and simplifying our programs surprisinglyfunctions are often used even when doing so actually makes program longer second reason for using functions is to make programs more