this is probably too simple of a question, but here I go.
I have paginated items, each page contains 100 items. The program fetches items till it reaches the item index specified within item_num
This is what I have:
item_num = 56
range(0, item_num/100 + (item_num%100 > 0)):
get_next_100()
I'm not really sure about the (item_num%100 > 0) boolean I used.
Is there anything wrong with what I did?
You seem to be trying to call the function zero times if item_num is 0, once if item_num is 1 to 100, twice if item_num is between 101 and 200, etc...
A simpler way to write this is:
n = 0
while n < item_num:
get_next_100()
n += 100
Or you could do it as a for loop:
for _ in range(0, item_num, 100):
get_next_100()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With