Check the following code:
def append(l=): l.append(1) return l
In my opinion, we have a problematic mutator function, but for the purpose of this article, just focus on the default argument/parameter. What's wrong?
def append(l=): l.append(1) return l print(append()) #  print(append()) # [1,1]
Here's the tricky default parameter: any object (list, map, etc) will be instantiate and will live in the memory for the rest of the function's life!
To avoid that stuff, you can check and instantiate every time, at the beginning of the function:
def immutableAppend(l=None): l =  if l is None else l l.append(1) return l print(immutableAppend()) #  print(immutableAppend()) # 
This gotcha leads me to the great Python Guide, which first gotcha is exactly this behavior. And one more reason to read all Python doc, again 😞 (search for "Important warning: The default value is evaluated only once").
You can test it on https://repl.it/@jotafeldmann/trickyDefaultArgument