Skip to content

Tag: python’s mutable list

Python’s mutable default arguments in the function definition and it’s side effects.

What is the output of this python code? The output. Why? For the benefit of those that are new to programming, I thought it would help to explain the code in a little bit more detail. In the code above we have a function definition declared using the keyword ‘def ‘. The name of the function is, ‘myList’. The function has two parameters surrounded by open and closed parentheses, and delimited by a comma. The first parameter is a variable named ” val “. The function’s second parameter is the… Read more Python’s mutable default arguments in the function definition and it’s side effects.