When using a Python list as an argument in a function, you might inadvertently change its value. For example, in the code above, using the append
method ends up changing the values of the original list.
If you want to avoid this side effect, use copy
with a list or deepcopy
with a nested list in a function.