Practice Test Geeks home

Python Functions and Scope Questions and Answers

A developer writes a function to log messages, intending for each call to start with a fresh list of tags unless specified.
However, they notice that tags from previous calls are persisting.

What is the most likely cause of this bug?

```python

def log_message(message, tags=[]):

tags.append('INFO')

print(f"{message}: {tags}")

log_message("System start")

log_message("User login")

```

Select your answer