I’m struggling trying to iterate every 10 items
So if the list is bellow 10 items it goes perfectly well of curse
If the list is bigger then for every y pressed I want to show the next 10 items like a next page button and also not blowing at the end if I try to get the last 10 items and there’s only 5 left
typing y to do next page and any other key previous page
Also note that this is not the real problem. The real one I’m facing is within curses module but I tried to simplify and even that I can’t
display = 0
list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
while True:
# tried this but I need button press
# for i in range(0, len(list), 10):
# print(*list[i:i+10])
if len(list) <= 10:
for i in list:
print(i)
else:
for i in range((display * 10), ((display * 10) + 10) ):
print(list[i])
np = input()
if np == 'y':
display += 1
# here something that would prevent the next page when there is no more items
else:
if display == 0:
display = 0
else:
display -= 1
2