Mutate In Place, Rebind Elsewhere
list_a = [1, 2, 3]
list_b = list_a
list_a.append(4)
print(list_b)
dict_a = {"x": 1}
dict_b = dict_a
dict_a = {"x": 2}
print(dict_b)
Two unrelated pairs of names, two different kinds of change. What do the two print calls output, in order?
Sign in to answer questions and track your progress
Sign In