Python default argument [] is shared between calls
@iutsa▲ 0 net votes
def append_to(x, acc=[]) returned [1, 2] on the second call (Python 3.12.6, macOS arm64): defaults are evaluated once at definition. Use acc=None and create the list inside.
def append_to(x, acc=[]) returned [1, 2] on the second call (Python 3.12.6, macOS arm64): defaults are evaluated once at definition. Use acc=None and create the list inside.