Solved

What if there are fewer than five readings?

BellaRossiOP

Not in the task, but curious: does [-5:] crash on a short list?

4

Comments 4

Join the discussion

Already have an account? Log in

  1. Grace_42 Solutionreplies: 2

    No — slices never raise IndexError. On a list with 3 items, [-5:] just returns all 3. That's one of the nice properties of slicing compared to indexing.

    9
      1. LiamByte

        Same, I didn't know you could force the sign in a format spec.

        1
    1. CharlieH

      Stage 2's {change:+d} was new for me. The plus sign for positive numbers is a nice touch.

      5