fix: forgot to return len() of list in function page_item_count. Insted list itself was returned

This commit is contained in:
Sandro Zimmermann 2026-03-09 20:20:52 +01:00
parent 7e43f0d42d
commit fa8b2b21f9

View File

@ -28,9 +28,11 @@ class PaginationHelper:
if page_index == 0: if page_index == 0:
return len(self.collection[: self.items_per_page]) return len(self.collection[: self.items_per_page])
return self.collection[ return len(
self.items_per_page * page_index : self.items_per_page * page_index * 2 self.collection[
] self.items_per_page * page_index : self.items_per_page * page_index * 2
]
)
# determines what page an item at the given index is on. Zero based indexes. # determines what page an item at the given index is on. Zero based indexes.
# this method should return -1 for item_index values that are out of range # this method should return -1 for item_index values that are out of range
@ -38,8 +40,8 @@ class PaginationHelper:
pass pass
collection = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j"] collection = ["a", "b", "c", "d", "e", "f"]
helper = PaginationHelper(collection, 4) helper = PaginationHelper(collection, 4)
print(helper.page_count()) print(helper.page_count())
print(helper.page_item_count(2)) print(helper.page_item_count(1))