W4_A1_subtlety in updating parameters

Yes, thanks for noticing and figuring out the underlying reason. The semantics of passing objects to functions in python can get you in trouble. You can use copy or deepcopy on the parameters dictionary to avoid this problem and still be able to use the “in-place” operators.

Here’s a thread which talks more about this case and points out some other issues with passing objects if you read the later posts on that thread.