Bookends

Python FundamentalsEasy+10 XP+10

Bookends

A weather station logs temperatures through the day. The report only needs the first and last reading.

Task: write first_and_last(readings) that returns a list holding the first reading, then the last one.

  • readings always has at least one value. If it has exactly one, that value is both first and last, so it appears twice.

Examples

readings = [12, 15, 19, 17]
returns [12, 17]
readings = [8, 3]
returns [8, 3]

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