All problems

Post List Pagination

Level 1 · python · Correctness · Boundary value (off-by-one)

Scenario

Implement get_page(posts, page, page_size), where page numbering starts at 1.

Requirements

- Page 1 returns the first page_size items - Out-of-range pages return an empty list - Items appear exactly once and in order

Acceptance criteria

  • Page 1 equals posts[0:page_size]
  • Concatenating consecutive pages reproduces the source list exactly
  • Out-of-range pages return an empty list