---
title: "Why Does a Python Default List Argument Keep Its Old Values?"  
description: "Why Does a Python Default List Argument Keep Its Old Values?"  
author: "Eetu Saarinen"  
published: 2026-10-27  
canonical: https://answers.mindstick.com/qa/118392/why-does-a-python-default-list-argument-keep-its-old-values  
category: "Mix Category"  
tags: ["Python", "programming", "Debugging"]  
reading_time: 1 minute  

---

# Why Does a Python Default List Argument Keep Its Old Values?

I ran into a Python behavior that surprised me: calling a function more than once seems to add to the same list, even though I expected a fresh one each time.

```python
def add_name(name, names=[]):
    # This default list is created once when Python defines the function.
    names.append(name)
    return names

print(add_name("Maya"))
print(add_name("Leo"))
```

Both calls return a list containing both names. Is this simply how a **mutable default argument** works, or is there a case where reusing that object is intentional? I’m also curious what the clearest alternative is when a function should start with a new list on every call.


---

Original Source: https://answers.mindstick.com/qa/118392/why-does-a-python-default-list-argument-keep-its-old-values

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
