Clone an Entity

Step 1 - Clone an Entity

The Prototype pattern creates new objects by copying an existing instance (the prototype) instead of building each one from scratch.

Implement Entity.clone() so it returns an independent deep copy of the entity. Use copy.deepcopy so nested data is duplicated, not shared.

Mutating a simple field on the clone must not affect the original.

Hints
Starter code
import copy


class Entity:
    def __init__(self, name, tags=None):
        self.name = name
        self.tags = list(tags) if tags is not None else []

    def clone(self):
        """Return an independent copy of this entity."""
        # TODO: return a deep copy of self using copy.deepcopy
        pass
Write it on a laptop

The editor and the test runner need a wide screen. Open this page on a desktop browser and your progress will be waiting.