Spot the bug in the deep-copy hook

from Shallow and deep copy
Python 3.14 intermediate 4 min 2 issues to find

Find the two memo mistakes in this generated deep-copy hook.

Python
import copy

class Node:
    def __init__(self, name):
        self.name = name
        self.children = []

    def __deepcopy__(self, memo):
        clone = type(self)(self.name)
        clone.children = [copy.deepcopy(child) for child in self.children]
        return clone
Open in playground
Report an error