for loop

Steven Bethard steven.bethard at
Sun Dec 12 18:27:20 CET 2004

houbahop wrote:
> for i=morethanzero to n

for i in range(morethanzero, n):

> for i= 5 to len(var)

for i in range(5, len(var)):

although range(len(var)) is usually not what you want, because you can 
just do:

for item in itertools.islice(var, 5, None):

or if you really do need the index too:

for i, item in itertools.islice(enumerate(var), 5, None):


More information about the Python-list mailing list