The Mutable Default Argument In Python
Summary: Passing mutable objects as default arguments leads to unexpected outputs because Python initializes the default mutable object only once, not (as you may have expected) each time the function is called. To fix this, initialize the mutable default argument with the None keyword in the argument list and then initialize it within the function. … Read more