Question #297

What is the output of the code snippet below?
def f(x):
    x.append(0)
    return x

my_list = []
f(my_list)
print(my_list)

Python functions have side effects! As lists are mutable, 0 will be appended to my_list will every time the function is called. (docs.python.org/2/faq/programming.html#what-are-the-rules...)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵