Use itertools.islice() if your indexes are long numbers:
from itertools import islice, count islice(count(start, step), (stop-start+step-1+2*(step<0))//step)
Python 3 range() can also handle long python.
Simplified your case:
for j in islice(count(1), num - 1):
source share