Question #113

What is the ouput of the code snippet below?
def change_list(my_list):
    my_list= [1, 2, 3, 4]
outer_list = ['a', 'b', 'c', 'd']
change_list(outer_list)
outer_list

In Python, arguments are passed by assignment. In the example above, when outer_list is passed as an argument to change_list() , only a reference to the list is actually passed. If the object is mutated within the function, the outer scope will know nothing about this mutation. (docs.python.org/3/faq/programming.html#how-do-i-write-a-f...)


Comment on Disqus:

Comment on Twitter:

Question difficulty: 🔵🔵🔵🔵🔵