Easiest way to include a stop parameter in enumerate python?
for i, row in enumerate(myiterable[2:], start=2):
if i>= limit: break
...
or
for i,row in itertools.takewhile(lambda (i,val):i < limit,enumerate(myiterable[2:],2)):
to rephrase the other suggestion (note that it will only work if your iterable is a sliceable object)
start,stop = 11,20
my_items = range(100)
for i,row in enumerate(my_items[start:stop],start):
....
I think you've misunderstood the 'start' keyword, it doesn't skip to the nth item in the iterable, it starts counting at n, for example:
for i, c in enumerate(['a', 'b', 'c'], start=5):
print i, c
gives:
5 a
6 b
7 c
For simple iterables like lists and tuples the simplest and fastest method is going to be something like:
obj = range(100)
start = 11
stop = 22
for i, item in enumerate(obj[start:stop], start=start):
pass