Skip to main content

Practice ยท 2 of 2

Pagination with honest metadata

Implement paginate(items, page=1, per_page=20) returning a dict with items (the window), page, per_page, total, total_pages (minimum 1), has_next (there are items after this window), has_prev (page > 1). - raise ValueError when page < 1 or per_page outside 1..100 (ints only) - an empty list is 1 page with has_next=False

Difficulty: advanced

Back to lesson: Practice: Contract Drills