Practice · Python

Practice Tuples & Unpacking

Create immutable tuples, unpack them into variables, and use them for grouped/multiple values.

Tuples & Unpackingwarming python…

Swap Player Coordinates

You are given a list of (x, y) coordinate tuples representing player positions on a field. Write a function swap_coords(points) that returns a new list where each coordinate is swapped to (y, x). Use tuple unpacking to perform the swap and do not modify the original list.

Example:

swap_coords([(1, 2), (3, 4)])  # returns [(2, 1), (4, 3)]
Press Run to see output, or Check to grade against the tests.

Want a whole course built around tuples & unpacking?

Start my path — free

Adaptive practice, streaks, projects with real code review. Free tier gates AI help, never content.