What does this program print?

from Shallow and deep copy
Python 3.14 beginner 2 min

What does this program print?

Python
import copy

source = {"items": [["pen"]]}
shallow = source.copy()
deep = copy.deepcopy(source)

shallow["items"][0].append("pencil")
deep["items"].append(["book"])

print(len(source["items"]), source["items"][0])
print(len(deep["items"]), deep["items"][0])
Open in playground
Report an error