python - How to enumerate starting with custom number -
using:
mylist=['one','two','three'[ i,each in enumerate(mylist): print i,each
results to:
0,'one' 1,'two' 2,'three'
as can see enumerate starts iterating i=0, 1, 2 , one. if start other 0 value, lets want 5. result be:
5,'one' 6,'two' 7,'three'
is doable?
just pass in starting number:
for i,each in enumerate(mylist,5): # <- start @ 5 mylist=['one','two','three'] i,each in enumerate(mylist,5): print i,each 5 1 6 2 7 3
Comments
Post a Comment