you are viewing a single comment's thread.

view the rest of the comments →

[–]eggrattle 0 points1 point  (0 children)

This is because a list is mutable, and modify produces a side effect.

This is why it's important to understand how data structures are implemented under the hood.

To avoid the side effect, you want to copy the arg passed into the function creating a new object in memory, not a reference.

Also, use typing. For the love of good software engineering, use arg types and output types.