A function has a list as the default value of a parameter. def add(x, bag=[]): bag.append(x) return bag add(1) add(2) print(add(3), add(4, [])) What does the program print?
[3] [4]
[1, 2, 3, 4] [4]
[3] [1, 2, 4]
[1, 2, 3] [4]
Log in to join the discussion.
Loading…