Move the Whole Shape

Python for AIMedium+10 XP+10

Move the Whole Shape

A drawing app stores a shape as a list of corner points. Each point is a tuple (x, y).

Task: write shift_shape(points, dx, dy). Return a new list of points where every point has moved by dx across and dy up — so (x, y) becomes (x + dx, y + dy).

  • Keep the points in the same order.
  • An empty shape gives back [].

Examples

points = [(0, 0), (2, 0), (2, 3)]
dx = 1
dy = -1
returns [[1, -1], [3, -1], [3, 2]]
points = [(5, 5)]
dx = 0
dy = 0
returns [[5, 5]]

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run