Swap the Bookends

Python FundamentalsMedium+10 XP+10

Swap the Bookends

In a photo booth strip, the first and last photos need to trade places.

Task: write swap_ends(photos) that swaps the first and last values of the list, then returns it.

  • Change the real list in place, then return that same list. Everything in the middle stays where it is.
  • photos always has at least one value. With just one, swapping it with itself changes nothing.

Examples

photos = ["smile", "wink", "laugh", "pout"]
returns ['pout', 'wink', 'laugh', 'smile']
photos = [1, 2]
returns [2, 1]

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