Append to a Mutable Default List

In this exercise, you are to define a function called mutable_default_argument. The function will take two parameters: an integer n and a list lst that defaults to an empty list.
The function should append the integer n to lst and return lst.
The first line of the input contains a single integer m, the number of times the function will be called. Each of the next m lines contains a single integer n, the number that will be appended to the list.
The output should contain m lines. Each line should be a list, representing the state of lst after each function call.
Input
Output
3 1 2 3
[1] [1, 2] [1, 2, 3]
4 10 20 30 40
[10] [10, 20] [10, 20, 30] [10, 20, 30, 40]
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue